Colleen:

I was expecting the facets returned would pertain to the search:result elements 
returned, rather than the index as a whole. However, I'm getting the same 
facets no matter what I use as the search string. Is there something else I 
need to do, or is my expectation misguided?

SS

From: [email protected] 
[mailto:[email protected]] On Behalf Of Colleen Whitney
Sent: Tuesday, September 01, 2009 5:56 PM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] RE: Problem with search:search and facets

Stewart:

Try adding an explicit collation to the range constraint definition (to match 
your range index, of course) on all string constraints:

<constraint name="highlight">
                <range type="xs:string" 
collation="http://marklogic.com/collation/"; facet="true">
                    <element ns="" name="highlight"/>
                    <facet-option>frequency-order</facet-option>
                    <facet-option>descending</facet-option>
                </range>
            </constraint>
--Colleen Whitney

From: [email protected] 
[mailto:[email protected]] On Behalf Of Stewart Shelline
Sent: Tuesday, September 01, 2009 4:28 PM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] Problem with search:search and facets

The following code works as expected (which proves the element range indexes 
exist and are working properly):

declare function local:get-query( $constraints as node()* ) {
    cts:and-query(
    for $i in $constraints//constraint
    return
        if( $i/@name = "comments" )
        then ( cts:element-query( xs:QName( "comments" ), cts:word-query( 
$i/text(), ( "lang=en","case-insensitive" ), 1), () ) )
        else ( cts:element-query( xs:QName( $i/@name ), $i/text()) )
    )
};

declare function local:search( $query ) {
    cts:search( doc()//annotation, $query )
};

declare function local:get-facets( $elementName, $query ) {
    cts:element-values( xs:QName( $elementName ), "*", ( "ascending" ), $query )
};

let $constraints :=
    <constraints>
        <constraint name="highlight">green</constraint>
        <constraint name="ug-tag">faith</constraint>
    </constraints>
let $query := local:get-query( $constraints )
let $hits := local:search( $query )
return <hits>{ $hits }</hits>

However, when I try to do the same thing with search:search, I get an error 
(XDMP-ELEMRIDXNOTFOUND) using the following code:

let $options :=
        <options xmlns="http://marklogic.com/appservices/search";>
            <debug>true</debug>
            <searchable-expression>//annotation</searchable-expression>
            <return-facets>true</return-facets>
             <constraint name="ug-tag">
                <range type="xs:string" facet="true">
                    <element ns="" name="ug-tag"/>
                    <facet-option>frequency-order</facet-option>
                    <facet-option>descending</facet-option>
                </range>
             </constraint>
             <constraint name="highlight">
                <range type="xs:string" facet="true">
                    <element ns="" name="highlight"/>
                    <facet-option>frequency-order</facet-option>
                    <facet-option>descending</facet-option>
                </range>
            </constraint>
            <constraint name="book">
                <range type="xs:string" facet="true">
                    <element ns="" name="annotation"/>
                    <attribute ns="" name="book"/>
                    <facet-option>frequency-order</facet-option>
                    <facet-option>descending</facet-option>
                </range>
             </constraint>
        </options>
    return search:search( "", $options )

I both cases, I am using the same element range indexes. The error occurs 
regardless of the collation used when setting up the indexes. When I execute 
the search:search function without debug on, it only blows up when I use a 
facet search parameter (e.g., highlight:green). However, if I just provide a 
simple keyword search, I get the expected results as well as the expected 
facets.

What am I missing?



NOTICE: This email message is for the sole use of the intended recipient(s) and 
may contain confidential and privileged information. Any unauthorized review, 
use, disclosure or distribution is prohibited. If you are not the intended 
recipient, please contact the sender by reply email and destroy all copies of 
the original message.

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to