Hi ,

I need to highlight search terms(<c>tags) and also build a search snippet 
within <a> tags.

Code:
let $snippet-length := 50
let $query :=  <cts:near-query distance="1">
<cts:or-query>
<cts:word-query weight="2">
  <cts:text>ELECTRIC</cts:text>
  <cts:option>unwildcarded</cts:option>
  <cts:option>case-insensitive</cts:option>
  <cts:option>stemmed</cts:option>
  </cts:word-query>
-<http://cpdb22288:8009/eval.xqy?iefix.txt> <cts:word-query weight="2">
  <cts:text>ELECTRIC</cts:text>
  <cts:option>unwildcarded</cts:option>
      <cts:option>case-insensitive</cts:option>
  <cts:option>unstemmed</cts:option>
  </cts:word-query>
  </cts:or-query>
<cts:or-query>
<cts:word-query weight="2">
  <cts:text>FAN</cts:text>
  <cts:option>unwildcarded</cts:option>
  <cts:option>case-insensitive</cts:option>
  <cts:option>stemmed</cts:option>
  </cts:word-query>

-    <cts:word-query weight="2">
  <cts:text>FAN</cts:text>
  <cts:option>unwildcarded</cts:option>
  <cts:option>case-insensitive</cts:option>
  <cts:option>unstemmed</cts:option>
  </cts:word-query>
-<http://cpdb22288:8009/eval.xqy?iefix.txt> <  <cts:option>ordered</cts:option>
  </cts:near-query>


let $docList :=
                             for $i in $docLists
                             let $start :=   cts:highlight($i,$query,
                 <a>
                 {

let $snippet_start := 
fn:string-join(fn:tokenize(fn:substring($cts:node,$cts:start - 
$snippet-length,$snippet-length*2)," ")," ")
                                               return
                                               $snippet_start
                   }
                  </a>)
return cts:highlight($start,$query,
                                               <b 
_.hit="{xdmp:set($highlightqueries,
                                                               
fn:distinct-values(fn:tokenize(fn:string-join(($highlightqueries,cts:word-query-text($cts:queries)),"
 ")," "))),
                                                                
fn:index-of($highlightqueries,cts:word-query-text($cts:queries))[fn:last()]}">
                                                                
<c>{$cts:text}</c>
                                                </b>)

But the results are getting repeated as:

<a>at or electric. This is an exploded view of a convertion when a spiral 
spring is used for the storage of fluid energy from a <.hit="1">
    <b>electric</b>
  </c> <.hit="2">
    <b>fan</b>
  </c>. SUBSTITUTE SHEET show the isometric views of another Automatic </a>
<a>This is an exploded view of a convertion when a spiral spring is used for 
the storage of fluid energy from a <.hit="1">
    <b>electric</b>
  </c> <.hit="2">
    <b>fan</b>
  </c>. SUBSTITUTE SHEET show the isometric views of another Automatic Latch 
u</a>
<a> n the prime mover is a <.hit="1">
    <b>Paddle</b>
  </c> <.hit="2">
    <b>fan</b>
  </c>. Due to its structure as shown, regardless of the direction of the fluid 
fiows, the <.hit="1">
    <b>electric</b>
  </c> <.hit="2">
    <b>fan</b>
  </c> will only be rotating in anticlockwise direction as looked from the top 
by the energy of the fluid flow. So the spiral 3=</a>

Expected output:

<a>at or electric. This is an exploded view of a convertion when a spiral 
spring is used for the storage of fluid energy from a <.hit="1">
    <b>electric</b>
  </c> <.hit="2">
    <b>fan</b>
  </c>. SUBSTITUTE SHEET show the isometric views of another Automatic </a>

<a> this is n the prime mover is a <.hit="1">
    <b>electric</b>
  </c> <.hit="2">
    <b>fan</b>
  </c>. Due to its structure as shown, regardless of the direction of the fluid 
fiows, the <.hit="1">
    <b>electric</b>
  </c> <.hit="2">
    <b>fan</b>
  </c> will only be rotating in anticlockwise direction as looked from the top 
by the energy of the fluid flow. So the spiral 3=</a>



**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not 
to copy, disclose, or distribute this e-mail or its contents to any other 
person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken 
every reasonable precaution to minimize this risk, but is not liable for any 
damage 
you may sustain as a result of any virus in this e-mail. You should carry out 
your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this 
e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to