Duplicate Results

This topic contains 13 replies, has 2 voices, and was last updated by dpotter0540 dpotter0540 2 years, 6 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #34365
    dpotter0540
    dpotter0540
    Participant

    My search instance displays ten random results automatically from a custom post type when the page loads. If there are more results, a Show More Results button appears at the bottom. These first ten results are fine. There is an issue of duplicate results appearing in the second batch of ten. For example, when I loaded the page just now and clicked the Show More Results button, ten additional results appears, but five of them were duplicates of the first ten results. In my browser’s Inspect feature I was able to confirm these are duplicate displays of the same custom post types as they share the same post IDs.

    Is there a way to prevent these duplicate results from appearing?

    Not sure if it helps, but I’m also customizing the format of these results via a vertical.php file in the asp directory of my custom theme.

    Also, Sources shows I’m only using this one custom post type for results, and there isn’t anything in Sources 2.

    Thank you so much for your help!

    #34375
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    It should not happen by default, as for each “batch” the original query is executed, and then the next N number of results are sliced from the results array. The query itself is distinctive by object ID, unless configured otherwise. Can you please check the General Options -> Grouping &Other results panel, the all options should be turned off: https://i.imgur.com/dgWZFoT.png

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34384
    dpotter0540
    dpotter0540
    Participant

    Everything under Grouping & Other is turned off.

    In using a javascript mutation observer, one thing I’m noticing is it seems the results are running twice each time. In the mutation observer I’m using querySelectorAll to list all the results. It should run one time and display ten nodes in the console.log. Instead, it runs twice. So I’m adding a data attribute on each result element when I add the listener, so that on the second run the listeners aren’t added a second time.

    #34385
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    That explains it then. If I may recommend, there is a javascript API for the plugin, with custom events. For example the asp_search_end event fires when the search is finished. You can use that event instead of the mutation observer if you want to. You may have to use the jquery on() event handler to attach to that event listener, because it is triggered via the jquery trigger() method, and I believe that does not trigger it as a native event.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34386
    dpotter0540
    dpotter0540
    Participant

    Ty for this alternative to using a mutation observer! The duplicate search results are happening even without a mutation observer running.

    #34394
    dpotter0540
    dpotter0540
    Participant

    Any ideas for how this apparent malfunction with Ajax Search Pro can be overcome?

    #34407
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Can we take a look at this somewhere? Can you please also add temporary FTP and back-end details?
    I have tried to replicate this issue on all of our local and remote test servers without any luck. I haven’t found any related tickets either, so this is something very specific.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34625
    dpotter0540
    dpotter0540
    Participant
    You cannot access this content.
    #34628
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    There is a known issue with the most recent release. Luckily there is a very simple fix. On the Compatibility options submenu, just change the javascript source to “Minified”: https://i.imgur.com/NP1NkHj.png
    Then clear all of your cache, and it should be fine afterwards. Let me know!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34633
    dpotter0540
    dpotter0540
    Participant

    Ty! I followed these steps and the results are now autopopulating. And in the second 10 results there are duplicates.

    #34635
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you!

    I found the issue – it was the difference in order of the auto-populate feature. For some reason the first set of items is not sent back via the form to exclude them, I need to investigate this further for the upcoming release.
    To temporarily resolve this, I recommend this configuration for the auto-populate feature for now: https://i.imgur.com/mREFF2g.png

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34873
    dpotter0540
    dpotter0540
    Participant

    Ty! Making this switch has stopped the duplicate results. Can I ask how likely it will be for the random results option to be functional again without duplicates?

    #34881
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    If you update to the latest release (4.21.3), it should work then.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34885
    dpotter0540
    dpotter0540
    Participant

    Awesome, thank you! Feel free to close this ticket.

Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘Duplicate Results’ is closed to new replies.