0

Is it possible to perform a structured query on server side javascript (via cts.* or jsearch.*) or on Node.js API?

According to documentation (https://docs.marklogic.com/guide/search-dev/structured-query#id_47703) it might only be possible only via XQuery, Java or REST API.

I was under the impression that XQuery and server side javascript implementation be have the same functionalities.

1 Answer 1

3

Equivalent expressive power does not necessarily mean identical interfaces.

Structured query is primarily intended for use with the REST, Java, and Node.js Client APIs. Use the Node.js Client API queryBuilder interface to construct a structured query. See http://docs.marklogic.com/guide/node-dev/search#id_28266.

Alternatively, if you do not want to use the builder for some reason, you can roll your own combined query that contains a structured query. See http://docs.marklogic.com/guide/node-dev/search#id_57610.

On the server side, the recommended search API for JS is jsearch. See http://docs.marklogic.com/js/jsearch and http://docs.marklogic.com/guide/search-dev/javascript#chapter. Jsearch operates on cts:queries. Structured query is really just a thin layer over cts:query.

It is possible to call search:resolve (as search.resolve) from JS, just like any other XQuery library, but it is XML-centric, so it is not very convenient to use it from JS.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, @kcoleman. I see you answered my other related question. Basically, I was hoping that structured query is what would help with my other question (stackoverflow.com/questions/45838688/…). Because it seems with structured query you can scope your search down to a certain level in an object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.