Hi, I need to get suggestions from <wl:search-text> but have to display <wl:title> values and also need to fetch <wl:entry id> attribute for each suggestions . For this I have used <transform-results> in options no results are coming.
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 namespace wl="http://www.lexisnexis.com/xmlschemas/content/legal/word-list/1/" ; declare function custom:my-snippet( $result as node(), $ctsquery as schema-element(cts:query), $options as element(search:transform-results)? ) as element(search:snippet) { let $dummy := xdmp:log (("custom"),"error") return <search:snippet> { ( search:snippet($result, $ctsquery, $options)/*, <extra>{$result//wordlist/(wl:body/wl:entries/wl:entry/wl:title)}</extra> ) } </search:snippet> }; Search_suggestion.xqy xquery version "1.0-ml"; declare namespace wl = "http://www.lexisnexis.com/xmlschemas/content/legal/word-list/1/"; import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy"; let $Q := "year" let $query := $Q let $dummy := xdmp:log (("In main"),"info") let $options := <options xmlns="http://marklogic.com/appservices/search"> <constraint name="test"> <range collation="http://marklogic.com/collation/" type="xs:string" facet="false"> <element ns="http://www.lexisnexis.com/xmlschemas/content/legal/word-list/1/" name="search-text"/> </range> </constraint> <suggestion-source ref="suggest" > <range collation="http://marklogic.com/collation/" type="xs:string" facet="false"> <element ns="http://www.lexisnexis.com/xmlschemas/content/legal/word-list/1/" name="search-text"/> </range> </suggestion-source> <term><term-option>punctuation-insensitive</term-option> <term-option>case-insensitive</term-option></term> <transform-results apply="my-snippet" ns="http://test.com/search" at="/custom.xqy" /> </options> let $finalquery := fn:concat("suggest:", $query) let $suggestions := search:suggest($finalquery, $options) return $suggestions Portion of Data.xml: - <<wl:entry id="6664" priority="2058905722"> < <wl:title>WRITTEN REQUEST FOR ACCESS ABC</wl:title> < <wl:search-text>WRITTEN REQUEST FOR ACCESS</wl:search-text> < <wl:related-entries /> < <wl:related-sources /> </wl:entry> - <<wl:entry id="6665" priority="1123685113"> < <wl:title>WTO XYZ</wl:title> < <wl:search-text>WTO</wl:search-text> < <wl:related-entries /> < <wl:related-sources /> </wl:entry> Please help me out with some sample code. Also let me know what I am missing. Also my dataset is huge so need to see the performance also Thanks Pragya
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
