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