Hi Mattio,
I would go with the first approach: "pass the <search:response> node off to another function and iterate through each <search:result>". The expensive part of your code will most likely be calls to the database. Although you are calling fn:doc for each item in the search results (ex: 10 calls to fn:doc if there are 10 search results), you are not doing any additional calls to cts:search, which is typically the most expensive part of your XQuery (search:search uses cts:search under the covers), so your code should not become too much slower. You might take a quick look at a generated application from the Application Builder (for example, the Oscars application) because the generated applications use the technique of calling fn:doc on each of the search results to get per-result-document metadata. David David Amusin Software Engineer Mark Logic Corporation 999 Skyway Road Suite 200 San Carlos, CA 94070 +1 650 207 2308 Cell +1 650 655 2310 Fax [email protected] www.marklogic.com This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us by returning this message to the sender and delete all copies. Thank you for your cooperation. On 7/1/09 4:17 PM, "Mattio Valentino" <[email protected]> wrote: First, I'd like to say thanks for releasing the Search API with 4.1! I'm hopeful that it can replace some of my existing code that I'm less than satisfied with. One of the first questions I have is about adding elements to <search:result>. When I return an item to the UI, I need to return some metadata as well -- title, author, etc. What's the best way to add this? One approach seemed to be to pass the <search:response> node off to another function and iterate through each <search:result>, but that optioned seemed to mean I'd be processing the same result item twice, once to process the original result and a second time to grab the metadata. A second option was cracking open search-impl.xqy where I was able to add the elements I needed after line 902 (attribute fitness {cts:fitness($result)},), but that option means it's more difficult for me to upgrade when the next release comes out, of course. Is there another option that I've missed? Can anyone recommend an approach? Thanks! Mattio _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
