简体   繁体   中英

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'

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM