Reputation: 1077
My objective is to implement typeahead search against a range index, within the result set defined by another structured query (my main search query). The use case is to search for available facet values (and frequencies) based on existing search results.
I thought the POST /v1/values/{name}
API would be a good fit but I have some confusion on how it works.
https://docs.marklogic.com/REST/POST/v1/values/[name]
According to the documentation, this API supports URL parameter q
defined as:
A string query. For details, see Automatic Query Text Parsing and Grammar in the Search Developer's Guide. This query is AND'd with the query(s) in the request body.
I may have misunderstood and thought this q
would search within the range index, similar to cts:value-match
. Apparently it is a regular string query searching the entire document by default?
Is it possible to use /v1/values/{name}
for my use case, or this is not what it is designed for? Could you please point me to the right direction? Thanks!
Upvotes: 1
Views: 83
Reputation: 20414
Dave is correct that the query parameters filter the docs, not the values. Search suggest is the most logical place to look for matching on values, but you can write custom code if that doesn't suffice. You can do that in the shape of a REST Extension, but I'd recommend looking at Data Services first, they are much more lightweight.
HTH!
Upvotes: 0
Reputation: 8422
The query is going to restrict which documents the values come from, rather than the values that are returned -- a slightly different use case.
Take a look at GET /v1/suggest, which can be configured to draw values from a range index or lexicon and is intended for exactly your use case.
Upvotes: 0