Search code examples
xquerymarklogicxml-database

Unfiltered Search Option does not return Accurate Results


In Marklogic, I have to do unfiltered search in order to return the results of the facets. But, this option returns inaccurate results that does not have Search highlight.
I used the searchable Expression in order to get the Path of the Search results, here is the options that I used:

<search-option>unfiltered</search-option>

<searchable-expression>
    /Book//chapter 
</searchable-expression>

<constraint name="chapter">
    <word> 
        <element name="chapter"/>
    </word> 
</constraint> 

<constraint name="Author">
    <range type="xs:string" collation="http://marklogic.com/collation/codepoint">
        <element name="author"/>
    </range>
</constraint> </options>

Also, I tried to add element query constraint, but it affect the performance of the search query This is the search query:

search:search("chapter:List of Scenes", $options);

Solution

  • (SO timed out) If you're getting no facets with filtered search, it's because the search didn't produce facets. An unfiltered search can produce facets on text that didn't match the search but was in the same document as a matching indexed term. Unfiltered searches are not a drop-in replacement for Filtered searches. If the Filtered searches are too slow then you should analyze your queries and data to find where optimizations are appropriate. Often a compromise is used - optimize a few searches to be fast, then use the results of those to do a 2nd filtered search on a subset of the results as needed to fill in the detail. See https://docs.marklogic.com/guide/performance.