[MarkLogic Dev General] Search - Additional Query

John Zhong john at yuxipacific.com
Tue Mar 13 06:26:45 PDT 2012


First comment is that you don't need the cts:and-query any more, it is said
that all the additional-query will be combined using a cts:and-query...

On Tue, Mar 13, 2012 at 9:15 PM, Vedavalli Radhika <radhika.kv at gmail.com>wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20120313/5b94ecd2/attachment.html 


More information about the General mailing list