1

I have a view-based search in my site. I notice that when I type a phrase like so "search terms" or even just search terms (no quotes) into the search box it returns all results that match that exact phrase as you'd expect BUT it also returns multiple versions of the same node!

I checked to make sure they are the exact same node and I think they are. One of these nodes is returned 6 times. I clicked on each linked result and the pathauto-altered URL is exactly the same for each. So for some reason it's returning it 6 times and I don't know why. Other nodes get returned fewer times. Some don't get returned more than once. I've checked some of the items that get returned multiple times in the mysql database and they appear to only be in there once...

I've cleared caches and run cron/re-indexed site...nothing.

I've got into 'find content' and looked to see if there are multiple copies of the nodes. Nope just the one.

And if, when I search, I just search for one word in the profile it only returns it once.

However, when I search for multiple terms I get multiple copies. I've reviewed the SQL of the returned view and it doesn't look like anything funky is going on.

Any idea why this might be happening?

2

There is a join in the query that is causing multiple instances of the same node to be returned.

Edit the view and under the "Other" section click on Query settings and choose Distinct.

The description says:

"This will make the view display only distinct items. If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it does not always work. Note that this can slow queries down, so use it with caution."

Here is the "Other section" in the view settings:

enter image description here

EDIT:

If this doesn't work then try the Views Distinct Module that Sage mentions in his comment below.

  • Hi, yes, you'd think that would work, but it doesn't. I also tried enabling aggregation, adding the nid field (and hiding it) and aggregating on the nid field with 'count distinct' and it's still displaying multiples of each node for some reason. I don't understand it's duplicates of the exact same node! and they don't even exist (as far as I can tell). – Sage Apr 24 '15 at 6:57
  • @Sage can you add the SQL generated by the view to the question as will make it easier to see what's going wrong – Felix Eve Apr 24 '15 at 7:19
  • 1
    thanks for your help. I 'solved' the problem by adding Views Distinct module. I'd rather add code but sometimes if it works it works. Turns out this is something Views just has problems with when you have complicated filtering mechanisms already in place (as I do). I think it has to do with each node having multiple selections for certain multiple select fields. Thanks for your help though. I'll give you correct answer since it would probably help some people with less complicated setups. – Sage Apr 24 '15 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.