0

With a text field, if I do a doc['my_text_field'] it shows analyzed tokens. As a result, the regex and wildcard queries can not be formulated in a resonable way...

Although, the text is available when doing adding a scripted field via params._source.my_text_field in its original form.

How do I get the unanalyed text like params._source.my_text_field for a normal elasticsearch query?

Muhammad Ali
  • 712
  • 7
  • 14
  • 2
    Just use "field.keyword" to query unparsed text. – Tom Slabbaert Nov 13 '19 at 13:39
  • the @tomslabbaert solution is the good one if you don't have a custom mapping. Of its solution does not work, please add your mapping to your question – Pierre Mallet Nov 13 '19 at 13:41
  • My mapping doesn't have a keyword for the 'string' field... That's the main issue. I tried the keyword and it doesn't seem to work – Muhammad Ali Nov 13 '19 at 14:43
  • Actually, now I recall that I did eventually use @TomSlabbaert suggestion. One issue we had was that there's a certain char limit on the keyword fields, and we had to drop the string afterwards. Regardless, this solved our problem. Thanks Tom! – Muhammad Ali Apr 01 '21 at 00:48

0 Answers0