Reputation: 121
I have read about cts:search()
and search:search()
separately but could not figure out the exact difference between them. It says cts:search()
ultimately uses search:search()
.
Can anyone illustrate in detail the scenario where one should go for cts:search()
and for search:search()
.This is not in relation to some particular project work where I need to implement this but in general.
Thanks!
Upvotes: 5
Views: 1449
Reputation: 20414
Also worth mentioning are the:
HTH!
Upvotes: 2
Reputation: 2137
The Search API (e.g. search:search()
) is an XQuery library that provides a high-level interface for some of the core capabilities of MarkLogic, such as search, facets, and aggregates. It uses the lower-level cts:*
(and other) libraries under the covers, but will save most developers a bunch of typing and debugging.
In general, I'd recommend starting with the Search API. We've put a lot of effort into making sure it's robust and fast. For example, when doing faceted search, it orchestrates getting the search results and calculating facets from range indexes in parallel. There are many other examples of conveniences and best practices that you get out-of-the-box with the Search API. If you need to do something more or different than the Search API provides, there are several places that allow you to work with lower-level cts:query
instances. For example, search:resolve()
takes a cts:query
and calls the equivalent of search:search()
.
Also, for those working in Server-Side JavaScript, the upcoming 8.0-4 release will introduce a similarly positioned high-level library designed specifically for JavaScript.
Upvotes: 15