OK, then the easiest approach will be to use query weightings.  The scale of 
weights is -16 to 16 and internally they're gradated into eights.

Give #4 a weight of 0.

Give #3 a weight of 0.0625.

Give #2 a weight of 1.5

Give #1 a weight of 16.

(You could also follow the original suggestion and do your own de-duping.)

-jh-

On Jun 27, 2011, at 5:47 AM, indar verma wrote:

> Hi Jason Hunter,
> Putting (cts:search(/x, $q1), cts:search(/y, $q2))[1 to 10] results into a 
> list,in this case duplicate results will come.suppose if a keyword "xyz" 
> found in x element and y element both and x and y elements are the part of 
> same document.so two results will be displayed but actually one result should 
> come.
> 
> Basically,I have to write a code that satisfy below scenarios:
>  if keyword found in:
> 1) only x element--give priority 1 
> 2) if x and y ---give priority 2
> 3) if max matches found in y --give priority--3
> 4) else 4
> 
> Thanks & Regards,
> Inji
> From: "[email protected]" 
> <[email protected]>
> To: [email protected]
> Sent: Mon, 27 June, 2011 4:05:38 AM
> Subject: General Digest, Vol 84, Issue 91
> 
> Send General mailing list submissions to
>     [email protected]
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>     http://developer.marklogic.com/mailman/listinfo/general
> or, via email, send a message with subject or body 'help' to
>     [email protected]
> 
> You can reach the person managing the list at
>     [email protected]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of General digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: Displaying results as per priority    (assigning weightage
>       to search results) (Jason Hunter)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Sun, 26 Jun 2011 15:33:33 -0700
> From: Jason Hunter <[email protected]>
> Subject: Re: [MarkLogic Dev General] Displaying results as per
>     priority    (assigning weightage to search results)
> To: General MarkLogic Developer Discussion
>     <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="windows-1252"
> 
> When you want one query to always prioritize over another, put them in a list.
> 
> (cts:search(/x, $q1), cts:search(/y, $q2))[1 to 10]
> 
> The server's lazy so it only does the second search if it doesn't get 10 from 
> the first.
> 
> -jh-
> 
> On Jun 25, 2011, at 12:46 PM, indar verma wrote:
> 
> > Hi All,
> > 
> > I have to implement  below logic:
> > it says:
> > a. First Look in document name and give Priority 1 - regardless
> > b. Then Look in metadata
> > c.  Third Look in full text
> >        i.      If it occurs in metadata only (Priority 2)
> >        ii.      If it occurs in metadata and full text (Priority 3)
> >        iii.      If it occurs in full text only (Priority 4 ? ranked by 
> > most occurrences
> > My XML structure is like that: 
> >  book1.xml
> > <book>
> >  <meta>
> > <field field-name=?document?>my doc</field>
> > <field field-name=?title?>This is a my doc<field>
> > ???..
> > </meta>
> >    <heading>Another1 abc</heading> 
> >    <para> 
> >        <text>This is part 2 of first document...</text> 
> >    </para> 
> > </book>
> > book2.xml
> > <book>
> >  <meta>
> > <field field-name=?document?>my document</field>
> > <field field-name=?title?>This is a my document<field>
> > ???..
> > </meta>
> >    <heading>Another document</heading> 
> >    <para> 
> >        <text>This is part 2 of first document...</text> 
> >    </para> 
> > </book>
> > book3.xml
> > <book>
> >  <meta>
> > <field field-name=?document?>my doc</field>
> > <field field-name=?title?>This is a my doc<field>
> > ???..
> > </meta>
> >    <heading>Another3 abc</heading> 
> >    <para> 
> >        <text>This is part 2 of first document...</text> 
> >    </para> 
> > <para> 
> >        <text>This is part 3 of first document...</text> 
> >    </para> 
> > </book>
> > as per my understanding of xQuery,we need to build query for metadata and 
> > text.so I built following xquery.
> > declare function local:build-query($text as xs:string) { 
> >  cts:or-query(( 
> >    cts:word-query($text, (), 1), 
> >    cts:element-word-query( 
> >      xs:QName("field"), $text, (), 2 )))  
> > }; 
> > let $query := local:build-query("document")
> > for $i in cts:search(/book, $query,("unfiltered","score-simple"))
> > return $i/heading
> > 
> > Please some one help me to optimize this code or if my approach is wrong 
> > then suggest me the logic/code.
> > 
> > Thanking in advance,
> > inji
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> http://developer.marklogic.com/pipermail/general/attachments/20110626/864791c6/attachment.html
>  
> 
> ------------------------------
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 
> 
> End of General Digest, Vol 84, Issue 91
> ***************************************
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

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

Reply via email to