Reputation: 4012
Let's say i have 2 documents:
<doc1>
<a>the dog</a>
<a>the cat</a>
<a>the human</a>
</doc1>
and
<doc2>
<a>the dog</a>
<a>foo</a>
<a>bar</a>
</doc2>
Now for Marklogic, i want to search them for 'the' so I might run:
search:search(
'a:the',
<options xmlns="http://marklogic.com/appservices/search">
<constraint name="a">
<value>
<term-option>case-insensitive</term-option>
<element ns="" name="a"/>
</value>
</constraint>
</options>
)
this works, but returns both documents (which is what i asked for) But what if I wanted only results that had more than 1 match on the constraint... ie. 'give me the documents that have 2+ nodes with "the"'
I have no idea where to start. Thanks!
Upvotes: 1
Views: 162
Reputation: 7842
The answers to your question at http://markmail.org/message/gaehhxnr7qb2un5p#query:+page:1+mid:vxjmjuh2wflofa67+state:results seemed good. Summarizing the thread, Rob and John both pointed out the min-occurs
option for cts:search
and Colleen added:
To enable that in the Search API you'd configure a word constraint on that element, adding
<term-option>min-occurs=2</term-option>
Mary noted that the index lookups would be
...accurate for simple cases like this as long as you have the right positions enabled.
If you run xdmp:plan over it and see min-occurs in the final plan, you have the right positions enabled.
Just to clarify: while Colleen mentioned a word constraint, http://docs.marklogic.com/cts:element-value-query shows the same option available for cts:element-value-query
. So you should be able to use it with a value constraint too.
Upvotes: 4