Nadia
Nadia

Reputation: 99

Wildcard searches

Our MarkLogic based web-application mostly uses cts.jsonPropertyValueQuery to access needed information. We want to provide the possibility of wildcard searches against specific JSON properties. What is the best way to do it?

Turning on one of the wildcard indexes for the whole database is not an option. I figured out that adding a "wildcarded" parameter to the query itself may solve the problem:

cts.search(cts.jsonPropertyValueQuery("inventor", "R?th", ["wildcarded", "whitespace-sensitive"])); 

But it may work slow due to the absence of indexes. Is there any way to create wildcard indexes only for that specific JSON property?

Upvotes: 1

Views: 137

Answers (1)

Mads Hansen
Mads Hansen

Reputation: 66723

You could create a Path Field with an XPath to the inventor JSON field (and even for //inventor) and configure the field to have wildcard indexes, and then use a field query: cts.fieldValueQuery or cts.fieldWordQuery.

Upvotes: 3

Related Questions