Dave, Ah! Makes sense. Thanks for the quick response.
Since I really only need to know whether total > page-length (so I can provide a link to the next page of results, if applicable), to avoid the extra processing perhaps I'll just ask for the desired page-length + 1 rather than asking for all results at once. Thanks, Greg On May 29, 2012, at 10:28 AM, Dave Cassel wrote: The total is (an estimate of) the number of fragments that match the query. Since all your matches are in one document (and presumably one fragment), the correct total is 1. Basically, it's answering a different question than the one you want to ask. The challenge, I'm thinking, is in knowing the total number of results so that you'll know how many pages to ask for. You could try picking some large value for page size to make sure you get them all at once. That won't take any longer to pull the document into memory, since it's all in one, though there will be more processing time spent building the search:result elements. On May 29, 2012, at 10:17 AM, Murray, Gregory wrote: 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("/ia-xml/h/hi/his/historyofinterpr00farr.xml")/*:doc/*:text/*:page[76]" score="228096" confidence="0.607176" fitness="0.782594"> <search:snippet> <search:match path="fn:doc("/ia-xml/h/hi/his/historyofinterpr00farr.xml")/*: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]<mailto:[email protected]> http://community.marklogic.com/mailman/listinfo/general David Cassel [email protected]<mailto:[email protected]> Sr. Federal Consultant, Vanguard Team Lead MarkLogic Corporation<http://marklogic.com/> _______________________________________________ General mailing list [email protected]<mailto:[email protected]> http://community.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://community.marklogic.com/mailman/listinfo/general
