Hi Srini, You can include additional information from the result document (such as an article title) by using a custom snippet function. You will need to include a transform-results node in your options XML with the attributes @apply, @ns, and @at. For details, see section 2.2.6.2 of the Search Developer's Guide here: http://developer.marklogic.com/pubs/4.1/books/search-dev-guide.pdf
Here is an example of a custom snippet that will include the node from the result document with the local-name "name". A node with QName "extra" will be included in the search:snippet node of every search result when search:search() is called. custom.xqy: xquery version "1.0-ml"; module namespace custom = "http://test.com/search"; import module namespace search = "http://marklogic.com/appservices/search " at "/MarkLogic/appservices/search/search.xqy"; declare function custom:my-snippet( $result as node(), $ctsquery as schema-element(cts:query), $options as element(search:transform-results)? ) as element(search:snippet) { <search:snippet> { ( search:snippet($result, $ctsquery, $options)/*, <extra>{$result//*:name}</extra> ) } </search:snippet> }; The call to search:search(): xquery version "1.0-ml"; import module namespace search = "http://marklogic.com/appservices/search " at "/MarkLogic/appservices/search/search.xqy"; search:search( "Gregory", <options xmlns="http://marklogic.com/appservices/search"> <transform-results apply="my-snippet" ns="http://test.com/search" at="/custom.xqy" /> </options> ) Please let me know if the explanation or example are unclear at all. Cheers, 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 On Oct 5, 2009, at 9:06 AM, Srinivas Mandadapu wrote: > Hi, > I am trying out developing a sample search which gives out a search > results with the highlighting tags. The simple search using > search:search outputs search results along with the highlighting tags. > If I need additional information in the search results, like an > title of > an article and any other additional information to appear in search > results, how should i go about it? > > Thanks, > Srini > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
