I am experiencing some unexpected functionality when I attempt to call 
search:snippet()

The snippet returned does not always have all the text that the original did, 
and does not always indicate the removal of text via an ellipses. This seems to 
happen when some of the text is in an anchor tag.

Following my message is a cq script that reproduces the bug (Notice the loss of 
the word topic in the second result returned).

-Mike

import module namespace search = "http://marklogic.com/appservices/search"; at 
"/MarkLogic/appservices/search/search.xqy";

let $results :=
<search:result index="1" uri="/published/foo.xml" 
path="fn:doc(&quot;/published/foo.xml&quot;)/webml" score="171" 
confidence="0.351263" fitness="0.861105" 
xmlns:search="http://marklogic.com/appservices/search";>
  <webml type="topic" uri="/study/topics/foo" xml:lang="eng" locale="eng" 
status="publish">
    <block type="heading" uri="/study/topics/foo.head">
      <div class="title">Foo</div>
      <div class="subTitle"/>
      <div class="definition">
        <p>
          Foo is the first <a href="/study/topics/topic">topic</a> of 
discussion. we will now discuss Foo...
        </p>
      </div>
    </block>
  </webml>
</search:result>

let $ctsquery :=
<cts:word-query qtextref="cts:text" xmlns:cts="http://marklogic.com/cts";>
  <cts:text>foo</cts:text>
  <cts:option>case-insensitive</cts:option>
</cts:word-query>

let $options :=
<search:transform-results apply="snippet" 
xmlns:search="http://marklogic.com/appservices/search";>
  <search:per-match-tokens>50</search:per-match-tokens>
  <search:max-matches>10</search:max-matches>
  <search:max-snippet-chars>1000</search:max-snippet-chars>
  <search:preferred-elements>
    <search:element name="block" ns=""/>
  </search:preferred-elements>
</search:transform-results>

return search:snippet($results, $ctsquery, $options)


 NOTICE: This email message is for the sole use of the intended recipient(s) 
and may contain confidential and privileged information. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you are not the 
intended recipient, please contact the sender by reply email and destroy all 
copies of the original message.


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

Reply via email to