PALLAVI
PALLAVI

Reputation: 21

What search options I can use to restrict the marklogic search API keyword search to not search in mentioned json property values?

What search options I can use to restrict the marklogic search API keyword search to not search in mentioned json property values? Let say I want search keyword 'x' in all json documents properties except property value of 'p' , 'q' and 'r'

Upvotes: 0

Views: 3324

Answers (1)

grtjn
grtjn

Reputation: 20414

There are a couple of approaches. The most literal approach would be to create value or word constraints for p, q and r, and do a not-search on them:

foo AND -(p:foo OR -q:foo OR -r:foo)

Alternative would be to play with fields, and use a field constraint. You could take a positive approach (only include fields you want to search), and do a positive search against that. Or you include the fields you don't want to search, and do a not-search on that.

The latter gives you more flexibility, yet saves you typing all properties that you like to exclude. Could be useful if you have to repeat that often. Consider appending that part automatically somewhere if you need to apply that in all searches..

HTH!

Upvotes: 2

Related Questions