[MarkLogic Dev General] False positives with element-query

Erik Hennum Erik.Hennum at marklogic.com
Fri Jul 24 08:56:55 PDT 2015


Hi, Basavaraj:

The element word, value, and range positions are all configured separately.  Since you're using element range queries, you would have to turn on element range value positions (which are configured on the same form that creates the element range index).

>From your answer, it sounds like you turned on element word positions, but maybe I'm misreading.


Erik Hennum

________________________________
From: general-bounces at developer.marklogic.com [general-bounces at developer.marklogic.com] on behalf of Basavaraj Kalloli [basavarajkalloli at gmail.com]
Sent: Friday, July 24, 2015 8:13 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] False positives with element-query


Hi Erik

Yeap we did try the position indexes for element and word positions but that still doesn't solve it. I believe Marklogic doesn't have any hierarchical indexes as in indexes for values located within the same element.

On Jul 24, 2015 6:04 PM, "Erik Hennum" <Erik.Hennum at marklogic.com<mailto:Erik.Hennum at marklogic.com>> wrote:
Hi, Basavaraj:

The best approach if at all possible is to put each size data row in a separate document instead of putting a size data table in a document.  That's a general recommendation for MarkLogic: treat a document as a row and a collection as a table.  Then, the unfiltered indexes will yield the rows you want.

Did you try turning on range value positions for your range indexes?


Hoping that helps,


Erik Hennum

________________________________
From: general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com>] on behalf of Basavaraj Kalloli [basavarajkalloli at gmail.com<mailto:basavarajkalloli at gmail.com>]
Sent: Friday, July 24, 2015 3:04 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] False positives with element-query

Hi,

We have a requirement where we need to search for min and max values which should occur within an element

For eg:


<SIZES>
   <SIZEDATA>
      <SIZE>12000</SIZE>
      <SIZE_MIN>12000</SIZE_MIN>
      <SIZE_MAX>12000</SIZE_MAX>
   </SIZEDATA>
   <SIZEDATA>
      <SIZE>3500</SIZE>
      <SIZE_MIN>3500</SIZE_MIN>
      <SIZE_MAX>3500</SIZE_MAX>
   </SIZEDATA>
</SIZES>

Given the above xml we need to search for min and max values in the range: 4000 and 5000. Now we have a element-query as:


import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";

let $size-min-query := cts:element-range-query(xs:QName("SIZE_MIN"),
                "<=", xs:double(4000), (), 0)
let $size-max-query := cts:element-range-query(xs:QName("SIZE_MAX"),
                ">=", xs:double(5000), (), 0)
let $and-query := cts:and-query(($size-min-query, $size-max-query))
let $q := cts:element-query(xs:QName("SIZEDATA"), $and-query)
let $options :=
    <options xmlns="http://marklogic.com/appservices/search">
        <search-option>unfiltered</search-option>
        <return-results>true</return-results>
    </options>

return search:resolve(<q>{$q}</q>/node(), $options)


If we run the above query this returns the document but ideally it shouldnt because the element's i.e SIZEDATA doesnt satisfy the range. If I change the options to use filtered search this works. We tried setting up element positions and word positions to on but still we still have false positive.

Any pointers or any other indexes which can help us?

_______________________________________________
General mailing list
General at developer.marklogic.com<mailto:General at developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20150724/19c9c33e/attachment.html 


More information about the General mailing list