Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count of facet and search differs from search result

Tags:

marklogic

When there is a character like underscore(_) and % in search string, results count and facets count do not match with search results.

I got one search result which is correct but result count and facet count come more than that. I am using search:parse and passing structured cts:query as parameter.

What may be the issue and it's resolution, please suggest.

like image 346
Pankaj Priyadarshi Avatar asked Mar 14 '23 07:03

Pankaj Priyadarshi


1 Answers

Your search results are being filtered, while the other values are not. When using Search API, the default behavior is to filter search results. This means essentially it first gets a candidate result set using only indexes, and then checks for and removes false positives. Facets and total result count can only be calculated using indexes, therefore they are never filtered.

There are a couple ways to handle this. The easiest is to specify the option <search-option>unfiltered</search-option>, and run your queries unfiltered. However, this means that any inaccuracies in facet and result counts will also be reflected in the search results.

The most accurate way is to configure your indexes and queries such that correct results can be returned using only indexes. This may take some trial and error. Generally, you want to be sure to use a searchable-expression that is also a document or fragment root. And in the case of your symbol characters, consider adding the exact option on your queries and enabling word position indexes. That might be enough to get it working in your case, however, for detailed information on this topic, see the Query Performance and Tuning Guide:

https://docs.marklogic.com/guide/performance/unfiltered

like image 104
wst Avatar answered May 09 '23 19:05

wst