Hi Michael,

The <cts:word-query..> in the script is the result of a search:parse
execution, then I cannot use the element-word-query. I need to get the
matches limiting the search to a specific element (in the document or in
the properties), and using the element-query retrieves the right results. I
tried using a constraint and it worked fine when the element was in the
document, but when the element is in the properties I could not make it
worked. Is there any other way to make it accurate instead of using the
"element word positions" index?

Thanks


On Thu, May 16, 2013 at 12:14 PM, Michael Blakeley <[email protected]>wrote:

> It looks to me like you could use an element-word-query instead of a
> nested element-query/word-query combination. That will be more efficient.
>
> http://docs.marklogic.com/cts:element-word-query
>
> Accurate results with element-query alone will often require element
> positions, for example the "element word positions" index. However
> positions require extra disk space and CPU time, so unless they are
> necessary I prefer to avoid them.
>
> http://docs.marklogic.com/guide/admin/text_index
>
> -- Mike
>
> On 16 May 2013, at 07:50 , Mauricio Valderrama Fonseca <[email protected]>
> wrote:
>
> > Hi All,
> >
> > I'm facing a problem using the search:resolve function, this is the
> xquery:
> >
> > xquery version "1.0-ml";
> > import module namespace dls = "http://marklogic.com/xdmp/dls"; at
> "/MarkLogic/dls.xqy";
> > import module namespace search="http://marklogic.com/appservices/search";
> at "/MarkLogic/appservices/search/search.xqy";
> >
> > let $query := <cts:and-query xmlns:cts="http://marklogic.com/cts";>
> >     { dls:documents-query() }
> >     <cts:not-query>
> >       <cts:collection-query>
> >       <cts:uri>error</cts:uri>
> >       <cts:uri>collection-A</cts:uri>
> >       <cts:uri>collection-B</cts:uri>
> >       </cts:collection-query>
> >     </cts:not-query>
> >     <cts:collection-query>
> >       <cts:uri>collection-C</cts:uri>
> >       <cts:uri>collection-D</cts:uri>
> >     </cts:collection-query>
> >     <cts:properties-query>
> >       <cts:element-query>
> >       <cts:element xmlns:ft="http://thecompany/facet
> ">ft:author</cts:element>
> >       <cts:word-query qtextref="cts:text" xmlns:xs="
> http://www.w3.org/2001/XMLSchema";>
> >         <cts:text>fiber</cts:text>
> >         <cts:option>case-insensitive</cts:option>
> >         <cts:option>diacritic-insensitive</cts:option>
> >         <cts:option>punctuation-insensitive</cts:option>
> >         <cts:option>whitespace-insensitive</cts:option>
> >         <cts:option>stemmed</cts:option>
> >         <cts:option>wildcarded</cts:option>
> >       </cts:word-query>
> >       </cts:element-query>
> >     </cts:properties-query>
> >   </cts:and-query>
> >
> > let $options := <options xmlns="http://marklogic.com/appservices/search
> ">
> >     <return-results>true</return-results>
> >     <constraint name="author">
> >       <range type="xs:string">
> >       <element ns="http://thecompany/facet"; name="author"/>
> >       <fragment-scope>properties</fragment-scope>
> >       <facet-option>concurrent</facet-option>
> >       <facet-option>item-order</facet-option>
> >       <facet-option>ascending</facet-option>
> >       <facet-option>limit=6</facet-option>
> >       </range>
> >     </constraint>
> >     <term>
> >       <term-option>case-insensitive</term-option>
> >       <term-option>diacritic-insensitive</term-option>
> >       <term-option>punctuation-insensitive</term-option>
> >       <term-option>whitespace-insensitive</term-option>
> >       <term-option>stemmed</term-option>
> >       <term-option>wildcarded</term-option>
> >     </term>
> >   </options>
> >
> > return search:resolve($query, $options)
> >
> >
> > The result is this one:
> >
> > <search:response total="32" start="1" page-length="10" xmlns=""
> xmlns:search="http://marklogic.com/appservices/search";>
> >   <search:facet name="author">
> >     <search:facet-value name="author 1" count="1">author
> 1</search:facet-value>
> >     <search:facet-value name="author 2" count="1">author
> 2</search:facet-value>
> >     <search:facet-value name="author 3" count="1">author
> 3</search:facet-value>
> >     <search:facet-value name="author 4" count="1">author
> 4</search:facet-value>
> >     <search:facet-value name="author 5" count="1">author
> 5</search:facet-value>
> >     <search:facet-value name="author 6" count="1">author
> 6</search:facet-value>
> >   </search:facet>
> >   <search:metrics>
> >     <search:query-resolution-time>PT0.007S</search:query-resolution-time>
> >     <search:facet-resolution-time>PT0.002S</search:facet-resolution-time>
> >     <search:snippet-resolution-time>PT0S</search:snippet-resolution-time>
> >     <search:total-time>PT0.01S</search:total-time>
> >   </search:metrics>
> > </search:response>
> >
> >
> >
> > In that case the facet is done using a element-range-index: <element ns="
> http://thecompany/facet"; name="author"/> this element is in the
> properties, but the result is inconsistent too if we use an element in the
> document. It is important to make notice that the facet and the results are
> CONSISTENT until we include a <cts:element-query> in the query.
> >
> > Watching the source, I noticed the functions: cts:element-values and
> cts:frequency are used to create the search:facet element. Then, I tried
> them directly and had the same result:
> >
> >
> > xquery version "1.0-ml";
> > import module namespace dls = "http://marklogic.com/xdmp/dls"; at
> "/MarkLogic/dls.xqy";
> >
> > let $facet-options := ("type=string", "properties", "descending",
> "frequency-order", "limit=6")
> > let $query := cts:document-fragment-query(
> >   cts:and-query((
> >     dls:documents-query(),
> >     cts:not-query(cts:collection-query(("error", "collection-A",
> "collection-B")), 1),
> >     cts:collection-query(("collection-C", "collection-D")),
> >     cts:properties-query(
> >       cts:element-query(
> >         fn:QName("http://thecompany/facet";, "author"),
> >         cts:word-query(
> >           "fiber",
> >
> ("case-insensitive","diacritic-insensitive","punctuation-insensitive","whitespace-insensitive","stemmed","wildcarded","lang=en"),
> >           1
> >         ),
> >         ()
> >       )
> >     )
> >   ), ())
> > )
> > return 
> > cts:element-values(fn:QName("http://thecompany/facet","author";),(),($facet-options,"concurrent"),$query,1,
> ())
> >
> >
> > The response was:
> >
> > author 1
> > author 2
> > author 3
> > author 4
> > author 5
> > author 6
> >
> > Now, executing a cts:search with the same $query value:
> >
> > xquery version "1.0-ml";
> > import module namespace dls = "http://marklogic.com/xdmp/dls"; at
> "/MarkLogic/dls.xqy";
> >
> > let $query := cts:document-fragment-query(
> >   cts:and-query((
> >     dls:documents-query(),
> >     cts:not-query(cts:collection-query(("error", "collection-A",
> "collection-B")), 1),
> >     cts:collection-query(("collection-C", "collection-D")),
> >     cts:properties-query(
> >       cts:element-query(
> >         fn:QName("http://thecompany/facet";, "author"),
> >         cts:word-query(
> >           "fiber",
> >
> ("case-insensitive","diacritic-insensitive","punctuation-insensitive","whitespace-insensitive","stemmed","wildcarded","lang=en"),
> >           1
> >         ),
> >         ()
> >       )
> >     )
> >   ), ())
> > )
> > return cts:search(fn:collection(),$query)
> >
> >
> > I got an empty sequence. Then the questions are: Why am I getting this
> inconsistencies when there is an element-query in the search? how can I
> avoid it?
> >
> > Thanks!
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>



-- 
Atentamente
Mauricio Valderrama Fonseca
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to