For example, if I ran a query like: SELECT * FROM [dam:Asset] WHERE ISDESCENDANTPATH([/content/dam/testfolder]) OPTION(LIMIT 10) the query engine would pick an index with queryPaths=/content/dam but not queryPaths=/content/dam/prodfolder
If you mismatch these values, the Query Engine will match your index for paths not contained in the index. Because the Query Engine uses the estimated count of nodes matching the query from the index evaluation to determine which index to use, this can mean that your index may even override OOTB index. This is because an index with a restrictive includedPaths (e.g. /content/dam/custom) and a permissive queryPaths (e.g. /content) will look like if filters out more non-matching results simply because it doesn’t contain them.
What all this means is that:
I would be remiss to not mention that there are rare use cases where you may want to set these values differently. If you have content that you do not want to ever appear in search, or you want to exclude content from a query with a broader path restriction, you can mismatch the includedPaths and queryPaths to support this. You can even include a base path and exclude additional paths with the excludedPaths property.
These are all edge cases and generally you’d be better of either updating the query or your content model rather than using the index to control this.
Hopefully you enjoyed this blog post. To continue to dive into Oak Search and Indexing, you can read more on my series Demystifying Oak Search: