0

I am executing an XQuery search against a word query to return values using co-occurrences. But the problem is that while executing a wild card search, then there are certain false positives that are returned as part of the matching documents. The element word query executed is

cts:element-word-query(fn:QName("", "contents"), "project monitor*", 
  ("case-insensitive","punctuation-insensitive","stemmed","lang=en"), 1)

The query which is executed is

cts:element-value-co-occurrences(xs:QName("node1"), xs:QName("node2"),                            
  ("collation=http://marklogic.com/collation/"),
  cts:and-query((
        cts:element-word-query(fn:QName("", "node3"), "project monitor*", ("case-insensitive","punctuation-insensitive","stemmed","lang=en"), 1),
        cts:element-range-query(
            xs:QName("node4"),
            "=",
            xs:long('1234567891011')
        ),
        cts:element-attribute-range-query(
            xs:QName("node5"),  
            xs:QName("attribute1"),  
            "=",
            ""
        ),
        cts:collection-query('collection1'),
        ()    
    ))
)

It is returning two matching results, which has one positive and one has a false positive items.

<cts:co-occurrence>
    <cts:value xsi:type="xs:string">General</cts:value>
    <cts:value xsi:type="xs:string">/pdf/text-document/12345_0_1234.xml</ct‌​s:value>
</cts:co-occurrence> 
<cts:co-occurrence>
   <cts:value xsi:type="xs:string">Other</cts:value>
   <cts:value xsi:type="xs:string">/pdf/text-doc/1234_1_0000.xml</cts:value>
</cts:co-occurrence>
wst
  • 11,681
  • 1
  • 24
  • 39
Kaustav Banerjee
  • 275
  • 1
  • 10
  • Can you post the two matches? It's likely related to your index settings. – wst Nov 02 '16 at 19:30
  • General /pdf/text-document/12345_0_1234.xml Other /pdf/text-doc/1234_1_0000.xml – Kaustav Banerjee Nov 02 '16 at 19:35
  • How are your documents structured? Are both of these values coming from the same document or different documents? What are the values that are matching the `cts:element-word-query` (the correct and the false positive one)? – wst Nov 02 '16 at 19:45
  • These are coming from different documents. There are no matches that are highlighted as matching snippets and that is particularly the issue. – Kaustav Banerjee Nov 02 '16 at 19:46
  • I think more important than the result of the co-occurrence would be to provide the actual document that gives the false positive against the search provided. – David Ennis -CleverLlamas.com Nov 02 '16 at 19:53

1 Answers1

3

Without a complete reproducible test case, my best guess is that a missing positional index is causing the wildcarded cts:element-word-query to return the false positive. Try enabling either or both: element word positions and element value positions in your database configuration and retry the query (after reindexing).

wst
  • 11,681
  • 1
  • 24
  • 39
  • Also note that the query run by [cts:element-value-co-occurrences()](https://docs.marklogic.com/7.0/guide/performance/unfiltered#id_89797) is evaluated as an unfiltered query. Showing a sample false-positive document would be helpful here. – Dave Cassel Nov 03 '16 at 13:59