To enable that in the Search API you'd configure a word constraint on that 
element, adding <term-option>min-occurs=2</term-option>.  Then reference it as: 
 a:the (assuming the constraint name is "a").
________________________________________
From: [email protected] 
[[email protected]] On Behalf Of Whitby, Rob, Springer 
Healthcare UK [[email protected]]
Sent: Friday, October 12, 2012 1:14 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] results that match a constraint X  
times(not just a single match)

Not sure about in the search api but with cts:search:

cts:search(
  fn:collection(),
  cts:element-word-query(xs:QName("a"), "the", "min-occurs=2"),
  "filtered"
)

It has to be filtered I think. Seeing as the term-frequency is used in 
calculating the score, I thought it might be possible to use cts:fitness in 
combination with score-logtf on the search and the unscaled-log db setting, but 
this doesn't seem to work as I (probably wrongly) expect.



-----Original Message-----
From: [email protected] on behalf of Marc Young
Sent: Fri 10/12/2012 20:24
To: [email protected]
Subject: [MarkLogic Dev General] results that match a constraint X times(not 
just a single match)

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!

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to