2

I have been working with cts:search in my project but somehow it feels the result time are taking a bit longer than expected. Can search:search help? If so, how?

For example I have the query as

let $query := cts:and-query((cts:element-value-query(xs:QName("Applicability"),"Yes"))) 

and I want to fetch the document URIs. I was using:

cts:search(collection("abc"), $query) 

and it returned the URIs, but how can this be extracted using search:search? Or is there something other than search can help for improving the execution time?

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • As a general note: search:search uses cts:search under the covers. cts:search and other cts functions are usually quicker, but more low-level. – grtjn May 03 '21 at 17:00

1 Answers1

3

Are you interested in retrieving the documents, or just the URIs?

If you are only looking to retrieve the URIs of the documents that have an element with that value, then use cts:uris() instead of cts:search(). The cts:uris() function runs unfiltered and will only return URIs from the lexicon, instead of retrieving all of the documents, which can be a lot more expensive than cts:search if you don't need the content.

cts:uris("", (), cts:and-query(( collection("abc"), $query)) ) 

When using cts:search, the first thing that I would try is to add the unfiltered option to your search and see if that helps.

By default cts:search executes filtered:

A filtered search (the default). Filtered searches eliminate any false-positive matches and properly resolve cases where there are multiple candidate matches within the same fragment. Filtered search results fully satisfy the specified cts:query.

So, try executing the same query with the "unfiltered" option:

cts:search(collection("abc"), $query, "unfiltered") 

You could also look to create an index on that Applicability element, with either an element-range-index or a field-range-index, and then use the appropriate range-query instead of a value-query.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • Thanks for your quick help!! I need content also but yes the unfiltered worked out for a better response time.Will try index creation also but need content hence cts:uris might not help much here ..!! – Ridam Jindal May 06 '21 at 06:43