Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

search:search() vs cts:search() in MarkLogic

Tags:

marklogic

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!

like image 907
Shabana Avatar asked Sep 03 '15 18:09

Shabana


People also ask

What is CTS MarkLogic?

cts:element-value-geospatial-co-occurrences. Returns value co-occurrences from the specified element value lexicon with the specified geospatial lexicon. cts:element-value-match. Returns values from the specified element value lexicon(s) that match the specified wildcard pattern.


2 Answers

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.

like image 142
Justin Makeig Avatar answered Dec 11 '22 07:12

Justin Makeig


Also worth mentioning are the:

  • Client REST API, which basically exposes the Search API as an HTTP interface
  • Java Client API, which exposes the Client REST API as a set of convenient Java objects, and methods
  • Node.js Client API, which exposes the Client REST API as a set of convenient Node.js objects, and methods

HTH!

like image 38
grtjn Avatar answered Dec 11 '22 07:12

grtjn