If field contains uppercase search


(Jeff Bursik) #1

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.

thanks!


(David Pilato) #2

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


(Jeff Bursik) #3

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?


(Jeff Bursik) #4

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

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

(David Pilato) #5

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.


(system) #6

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