If field contains uppercase search

Is there a way to determine if the field's value contains any upper case?

For example, I have 2 documents with field name. Doc1 = { name: jeff }. Doc2 = { name = Jeff}. I only want Doc2 returned since the "J" is capital.


Change the default analyzer to a custom analyzer which does not apply a lowercase token filter. Or use a keyword data type.

Maybe I didn't state my question correctly, or I'm just not sure how an analyzer would be used here but I'm looking for a query like:

GET _search
"name.keyword": "contains caps"

I'm not sure how an analyzer would help with that?

After some more trial, found a regex query to do what I'm looking for:

      "regexp": {
        "name.keyword": "(.*[A-Z].*)"

I see. If this is a one shot only operation than your method is OK.
If this is something you are going to run every time, I'd suggest that you compute something like a boolean containsUpperCase that you compute at index time and then just query it.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.