Hello,

Using the Search API, I'm performing searches within a single document. The 
idea is to display (in a web app) a snippet for every search result within a 
given document. The documents are digital books with this structure:

<doc xmlns="http://digital.library.ptsem.edu/ia";>
  <metadata>
    <!-- title, author name, etc. -->
  </metadata>
  <text type="ocr">
    <page>
      <!-- content of page -->
    </page>
    <page>
      <!-- content of page -->
   </page>
    <!-- more pages -->
  </text>
</doc>

I'm using <searchable-expression> like so

    <options xmlns="http://marklogic.com/appservices/search";>
      <additional-query>{cts:document-query($uri)}</additional-query>
      <searchable-expression 
xmlns:ia="http://digital.library.ptsem.edu/ia";>/ia:doc/ia:text/ia:page</searchable-expression>
    </options>

to get search results at the page level -- that is, results in which @path of 
each result indicates the page where the searched-for-term occurs:

<search:response total="1" start="1" page-length="10" 
xmlns:search="http://marklogic.com/appservices/search";>
  <search:result index="1" uri="/ia-xml/h/hi/his/historyofinterpr00farr.xml" 
path="fn:doc(&quot;/ia-xml/h/hi/his/historyofinterpr00farr.xml&quot;)/*:doc/*:text/*:page[76]"
 score="228096" confidence="0.607176" fitness="0.782594">
    <search:snippet>
      <search:match 
path="fn:doc(&quot;/ia-xml/h/hi/his/historyofinterpr00farr.xml&quot;)/*:doc/*:text/*:page[76]">
        ...data of the Written Law. The gigantic edifice of the Talmud really 
rests on the
        <search:highlight>hermeneutic</search:highlight> rules of Hillel as 
upon its most solid
        base. These rules ...
      </search:match>
    </search:snippet>
  </search:result>
  <!-- results 2 - 10 here -->
</search:response>

What I find odd is the value of @total. There are at least 10 search results 
total, because @page-length = 10 and there are 10 <search:result> elements, but 
@total = 1 -- so it's clear that @total is indicating the total number of 
*documents containing results*, not the total number of *results*. I was 
expecting the latter. Is this a bug or a feature?

Thanks,
Greg

Gregory Murray
Digital Library Application Developer
Princeton Theological Seminary

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

Reply via email to