xquery - How to do a multiple term search within an element -
i attempting search checks each word within query string contained within specific element. example, if $query = "sports stripes"
specific element must contain 3 words (in order, not phrase).
to restrict search element have following constraint:
<constraint name="inelement"> <word> <element ns="" name="myelement"/> <term-option>case-insensitive</term-option> </word> </constraint>
this seems okay, struggling when comes put in search:search
. first attempted this:
search:search('inelement:spots stripes', $options, 1, 25)
this did not work restricts "spots"
element.
i tried following, me results need wondering if way achieve or if there way such using operator in-between search terms.
search:search('inelement:spots inelement:with inelement:stripes', $options, 1, 25)
is there better way? or manually have parse querystring separate them in individual words before adding constraint search:search
?
to apply constraint across whitespace, use quotes.
inelement:"spots stripes"
with default parser return single element-word term. break term words, write custom parser function. there example @ http://docs.marklogic.com/guide/search-dev/search-api#id_49750
you may want cts:near-query
ensure 3 words in same element. , may need enable element-word-positions
in database configuration.
Comments
Post a Comment