Search code examples
xquerymarklogic

How to handle case-insensitive in Marklogic


I am using fn:distinct-values but I have faced case sensitive problems.

I need to remove the duplicate values in MarkLogic db.

 Result :
    Antony
    antony

but I want to one result without any duplicate either:

Antony or antony.


Solution

  • It's all about collations.

    I would suggest that you add a lexicon to whatever attribute or element or property you are referring to. When you set up the lexicon, you can then define the collation to take care of this. In the end, no 'distinct values' is needed because the lexicon will already have a distinct list.

    You could use 'distinct values' if you were to normalize your content using uppercase or lowercase in a FLWOR statement in your code, but this is much more costly.

    For your reference:

    https://docs.marklogic.com/guide/search-dev/encodings_collations https://docs.marklogic.com/guide/search-dev/lexicon