Dixit Singla
Dixit Singla

Reputation: 2620

case-insensitive with unfiltered search returning wrong results in MarkLogic

There seems to be a problem related to unfiltered and case-sensitive search.

I am running an element-value-query with case-sensitive option.

The unfiltered cts search returning me the wrong results.

Following code snippet exhibit the wrong behavior.

case 1:

xdmp:document-insert('/a.xml', <a><name>Dixit</name></a>);

cts:search(
  doc('/a.xml'),
  cts:element-value-query(xs:QName('name'), 'dixit','case-sensitive'),
  'unfiltered'
);

output: returning me the inserted xml

Expected: it should not return

Here I thought in the indexes, the key Dixit is equal to 'dixit' hence returning me the XML.

So I tried the below one but no gain.

case 2:

xdmp:document-insert('/a.xml', <a><name>Dixit singla</name></a>);

cts:search(
  doc('/a.xml'),
  cts:element-value-query(xs:QName('name'), 'dixit singla','case-sensitive'),
  'unfiltered'
);

output: returning the inserted xml

Expected: it should not return

Is it a bug in MarkLogic or this is the expected behavior. I am curious to know the reason.

Note: fast case sensitive searches & fast diacritic sensitive searches both indexes are set to true.

Upvotes: 2

Views: 117

Answers (1)

mholstege
mholstege

Reputation: 4912

This is a somewhat different matter than referenced above.

Index resolution depends on key-matching in the universal index. It turns out the case-insensitive key for "Dixit" is the same as the case-sensitive key for "dixit" because the way case-insensitive keys are computed is to compute the key of the lowercased form of the word. Therefore at the point we compare keys, there is a key that matches case-sensitive "dixit" so the indexes return a match. Index resolution can accurately require that capitalized words in the query match only capitalized words in the document, but not that lowercased words in the query match only lowercased words in the document. You'll need to filter to get accurate results here.

Upvotes: 5

Related Questions