1
votes

In MarkLogic REST API /v1/suggest, I can use constraint defined in persisted query options in partial-q. I am not sure how to accomplish the same task using the MarkLogic NodeJS client. According to the documentation, it seems the only way I can reference persisted query options is through combined query. I see it works for document search, but I don't know if and how it would work for suggest.

https://docs.marklogic.com/guide/node-dev/search#id_57610

Thank you!

1
I am not sure it works with typeahead suggestions, but support for persisted search options was built-in as mentioned here stackoverflow.com/a/58624280/918496grtjn
Hi @grtjn. As I discussed in my own answer, the Document.suggest method does not pass optionsName to the underneath REST API as the Document.query method does.Fan Li

1 Answers

0
votes

Going over the source code, I see that support for persisted query options is only available for the Documents.query method: https://github.com/marklogic/node-client-api/blob/master/lib/documents.js#L1862

var optionsName = wrapper.optionsName;
...
if (optionsName != null) {
  endpoint += '&options='+optionsName;
}

It is straightforward to do the same for the Documents.suggest method - not sure why it is missing. For now, I just need to override the Documents.suggest method to add the several lines of code shown above.