[MarkLogic Dev General] Search - Additional Query

Danny Sokolsky Danny.Sokolsky at marklogic.com
Tue Mar 13 14:41:52 PDT 2012


That is not a valid options node you have.  I see several problems with it:

1) it is not in the http://marklogic.com/appservices/search namespace
2) there are 2 additional-query elements.  If you want to combine them, make an and-query of the 2 additional-query elements.
3) the second additional-query is not a query, it is a search.

I recommend using search:check-options on your options node to make sure it is valid (or adding the <debug>true</debug> option to your options node.

So maybe try fixing the options node and see if that gets you any farther.

-Danny


-----Original Message-----
From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Vedavalli Radhika
Sent: Tuesday, March 13, 2012 6:15 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Search - Additional Query

I wrongly typed the current query that I am using,
It is the below:
"let $options :=
<options>

    <additional-query>{cts:directory-query("/my-directory/",
"infinity")}</additional-query>
    <additional-query>{cts:and-query(cts:element-value-query(xs:QName("sc:filtertype"),"source"))}</additional-query>

    <constraint name="source">
        <range type="xs:string" facet="true"
collation="http://marklogic.com/collation/">
                          <element ns="my-namespace" name="filtervalue" />
 		   <attribute name="name" />
                          <facet-option>frequency-order</facet-option>
        </range>
    </constraint>
</options>

let $result := mlsearch:search($queryString ,$options)

return $result"


On 3/13/12, Vedavalli Radhika <radhika.kv at gmail.com> wrote:
> For the given format of xmls, I have to form facets of filtertype
> elements which has filtertype value as "source" alone.
>
> <ns8:activityitem>
> <ns5:filterlist>
> <ns2:filterlist><ns2:filter>
> <ns2:filtertype name="Source">source</ns2:filtertype>
> <ns2:filtervalue name="ABCD">ABCDE</ns2:filtervalue>
> <ns2:filtervalue name="1234">12345</ns2:filtervalue>
> </ns2:filter>
> </ns2:filterlist>
> <ns2:filterlist>
> <ns2:filter>
> <ns2:filtertype name="Source">domain</ns2:filtertype>
> <ns2:filtervalue name="FIVE">FIVES</ns2:filtervalue>
> </ns2:filter>
> </ns2:filterlist>
> </ns5:filterlist>
> </ns8:activityitem_marklogic>
>
> For the following code,
>
> let $options :=
> <options>
>
>     <additional-query>{cts:directory-query("/my-directory/",
> "infinity")}</additional-query>
> <additional-query>{for $x in cts:search(//cdi:filterlist,
> cts:directory-query("/my-directory/","infinity"))
> return $x/sc:filterlist/sc:filter[sc:filtertype eq
> "source"]/sc:filtervalue}</additional-query>
>
>     <constraint name="source">
>         <range type="xs:string" facet="true"
> collation="http://marklogic.com/collation/">
>                           <element ns="my-namespace" name="filtervalue" />
>  		   <attribute name="name" />
>                           <facet-option>frequency-order</facet-option>
>         </range>
>     </constraint>
> </options>
>
> let $result := mlsearch:search($queryString ,$options)
>
> return $result
>
> The facet results are as follows:
> <search:facet name="source">
> <search:facet-value name="ABCD" count="1">ABCD</search:facet-value>
> <search:facet-value name="1234" count="1">1234</search:facet-value>
> <search:facet-value name="FIVE" count="1">FIVE</search:facet-value>
> </search:facet>
>
> But whereas I expect only the first two entries.
> The query is returning all filtervalues in the given xml whenever it
> finds a filtertype element in it's xml with value as "source".
> But I am expecting only the filtervalues for which the sibling node
> filtertype has value as source.
>
> I tried to build a xquery using xpath. This is giving me expected
> results. But I am unable to fit this in the additional-query.
>
> for $x in cts:search(//ns5:filterlist,
> cts:directory-query("/my-directory/","infinity"))
> return $x/sc:filterlist/sc:filter[sc:filtertype eq "source"]/sc:filtervalue
>
> When I include the above inside additional-query, I am getting the
> following exception.
> "XDMP-QUERYELEM: cts:query(<cts:and-query
> xmlns:cts="http://marklogic.com/cts"><cts:and-query strength="20"
> qtextjoin=""><cts:and-query qtextco...</cts:and-query>) -- Query
> element contains unknown child: /cts:and-query"
>
> 1. Please help me resolve the issue.
> 2. I am also not sure if the above way is the best way to solve the
> problem. Give me your suggestions on how can I best(in terms of
> performance) solve the issue at hand.
>
> Thanks,
> Radhika.
>
_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


More information about the General mailing list