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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With