Hi Adam, If you are really only searching a single document and want to know the number of hits in that document, one approach could be to set the max-matches in transform-results to a large number, then count the search:match elements in the output from search:search. Then you can do a count of the search:match elements. Something like:
xquery version "1.0-ml"; import module namespace search="http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy"; fn:count( search:search("hello", <options xmlns="http://marklogic.com/appservices/search"> <transform-results apply="snippet"> <per-match-tokens>30</per-match-tokens> <max-matches>200</max-matches> <max-snippet-chars>2000</max-snippet-chars> <preferred-elements/> </transform-results> </options>) /search:result[1]/search:snippet/search:match) -Danny From: [email protected] [mailto:[email protected]] On Behalf Of Adam Patterson Sent: Friday, March 19, 2010 12:06 PM To: General Mark Logic Developer Discussion Subject: [MarkLogic Dev General] Search:search total Hi, I'm using search:search to search a single document in my database. I accomplish this by having an additional-query, a cts:document-query, in my search options. I understand from the online documentation that search:search returns the total number of documents which the search hit on in the total attribute. I'm wondering if there's a way to tell search:search that I want the total number of hits (at the node level) which the search produced, and I do not want the number of documents as it's always "1". I've also tried using search:estimate with the query returned by search:search with <return-query>{fn:true()}</return-query> set in the search options, and I'm sure you're not surprised to hear that I get the exact same results. Any thoughts are appreciated. Cheers, Adam
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
