MarkLogic : Design question on search.search Vs CTS APIs

59 Views Asked by At

MarkLogic version 9.0-6

Our team creates a bunch of custom REST APIs (v1/resources/...) and expose them as enterprise services to other stakeholders, who do not need to know anything about MarkLogic. However, our team is responsible for creating, enhancing and maintaining the server-side scripting (we use JavaScript) within MarkLogic.

While creating custom REST APIs, our current design is to use search.search API to meet any search requirements. Lately, I am inclining more towards using the more flexible and faster CTS functions as I do not see any specific advantages of using search.search wrapper API. As my team's job is primarily to code and maintain server side scripts, I think its better to use the low level APIs (CTS functions) that offer greater flexibility and speed, than investing time on making the high level APIs (search.search or jsearch) work, or even worse, re-code to CTS functions later in the future because a specific complex functionality cannot be achieved through high level APIs.

Design gurus, please suggest!

1

There are 1 best solutions below

0
On

JSearch, Search API, Optic API, all very good tools, developed and maintained by the MarkLogic Core Engineering team. I'd think long and hard before putting them aside. Whether that is wise in your case, that might depend. Maybe you overlooked functions that would be of great help to you. For instance, some limitations with Search API can be overcome by using search.parse() and search.resolve() instead of search.search(). Using CTS directly is not a bad practice, but you could easily end up re-inventing the wheel.

Ask specific questions, and share specific pieces of code with relevant questions to get specific answers. This forum is not really suited for open questions like these, as they often don't have a straight and clear answer.

HTH!