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
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general