2

Problem

My view based on Search API is giving me duplicate results. I get duplicate results if I use the following things in combination:

  • A pager
  • A sort of any kind. e.g. Sort by ascending integers, sort by descending select field etc.

Sometimes I get a couple duplicate results, other times entire pages are identical.

According to the module page I should be able to use view sorts on single valued indexed fields, but I can't seem to get this to work at all.

Has anyone else run into this? How did you solve it?

Common solutions for duplicate results

Most of the solutions I've spotted for this involve options which don't appear for Search API. They usually involve adding aggregation or distinct filters in the Views options.

The possible solution here fails. The problem is it searches for duplicate results only amongst the current page of the view.

i.e. if I get 60 nodes on a search with a pager of 15, this splits into 4 pages. If the duplicates are on pages 1 & 3 then they're not spotted.

1 Answer 1

0

Bleh what a horrible bug.

I solved it by re-creating the search index (and therefore the view as well).

Why did it happen?

I think it's possible to have certain things saved into the Search Index (possibly when it's created?) and then it's impossible to remove them without just starting afresh.

I discovered this bug while trying to debug this.

After re-creating the new index the only difference I can find between it and the original is that I can now sort by an un-related taxonomy field (see the bug). Presumably this is an indicator of something as it doesn't seem relevant, but I have no idea what.

Second EDIT:

Actually just re-creating the index wasn't enough to solve this problem, I then continued to find duplicates after.

Deleting and re-creating the field with a new ID however did work. I never worked out why, but I'm presuming something was corrupted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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