Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Duplicate Results
- This topic has 13 replies, 2 voices, and was last updated 4 years, 8 months ago by
dpotter0540.
-
AuthorPosts
-
August 25, 2021 at 3:05 am #34365
dpotter0540
ParticipantMy 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!
August 25, 2021 at 12:36 pm #34375Ernest Marcinko
KeymasterHi,
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 &Otherresults panel, the all options should be turned off: https://i.imgur.com/dgWZFoT.pngAugust 25, 2021 at 11:08 pm #34384dpotter0540
ParticipantEverything 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.
August 26, 2021 at 7:50 am #34385Ernest Marcinko
KeymasterThat 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.
August 26, 2021 at 8:15 am #34386dpotter0540
ParticipantTy for this alternative to using a mutation observer! The duplicate search results are happening even without a mutation observer running.
August 28, 2021 at 11:18 pm #34394dpotter0540
ParticipantAny ideas for how this apparent malfunction with Ajax Search Pro can be overcome?
August 30, 2021 at 9:37 am #34407Ernest Marcinko
KeymasterCan 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.September 9, 2021 at 8:05 am #34625dpotter0540
ParticipantYou cannot access this content.
September 9, 2021 at 8:46 am #34628Ernest Marcinko
KeymasterThere 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!September 9, 2021 at 9:15 am #34633dpotter0540
ParticipantTy! I followed these steps and the results are now autopopulating. And in the second 10 results there are duplicates.
September 9, 2021 at 9:29 am #34635Ernest Marcinko
KeymasterThank 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.pngSeptember 21, 2021 at 7:59 pm #34873dpotter0540
ParticipantTy! 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?
September 27, 2021 at 4:53 pm #34881Ernest Marcinko
KeymasterIf you update to the latest release (4.21.3), it should work then.
September 27, 2021 at 10:02 pm #34885dpotter0540
ParticipantAwesome, thank you! Feel free to close this ticket.
-
AuthorPosts
- The topic ‘Duplicate Results’ is closed to new replies.