Hi there,

I'm trying to declare a custom search grammar. I declared a custom function via 
search options, which supposed to parse "BOOST" keyword:

<joiner strength="2" apply="custom-boost" 
ns="http://worldbankgroup.org/search/grammar"; at="/lib/grammar-boost.xqy" 
tokenize="word">BOOST</joiner>

I declared this function and just copied existing implementation from 
impl:joiner-boost function in /MarkLogic/appservices/search/search-impl.xqy :

declare function grammar:custom-boost($ps as map:map, $left as element()?, 
$opts as element()?) as schema-element(cts:query) {
    let $symbol := impl:symbol-lookup($ps)
    let $_ := tdop:advance($ps)
    let $expr1 := tdop:expression($ps, $symbol/@strength)
    return
        if (empty($left))
        then ($left, impl:msg($ps, <cts:annotation 
warning="SEARCH-IGNOREDQTEXT:[{string($symbol)} {$expr1}]: expected two 
arguments"/>))
        else
            element { xs:QName($symbol/@element) } {
                attribute qtextjoin {concat($symbol/string())},
                attribute strength {$symbol/@strength},
                attribute qtextgroup { 
impl:opts($ps)/opt:grammar/opt:starter[@apply eq "grouping"]/(string(), 
@delimiter/string()) },
                for $opt in 
$symbol/@options/tokenize(normalize-space(.)<mailto:$symbol/@options/tokenize(normalize-space(.)>,
 "\s") return <cts:option>{$opt}</cts:option>,
                element cts:matching-query {
                    attribute qtextref { "schema-element(cts:query)" },
                    $left },
                element cts:boosting-query {
                    attribute qtextref { "schema-element(cts:query)" },
                    $expr1 }
            }
};

Unfortunately this doesn't work, because for some reason impl:symbol-lookup 
returns an empty sequence.
Any ideas what went wrong here?


Oleksii Segeda

IT Analyst

Information and Technology Solutions

[http://siteresources.worldbank.org/NEWS/Images/spacer.png]

[http://siteresources.worldbank.org/NEWS/Images/WBG_Information_and_Technology_Solutions.png]



_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to