Emil Revencu
Emil Revencu

Reputation: 89

How to find in ElasticSearch for values which matches the string?

I have stored values for example:

  1. "ABC,DEF"
  2. "ABC,34,DEF"
  3. "ABC,DEF,FGH"
  4. "ABC-FGH-DEF"
  5. ",,ABC-DEF"

I need to query for values which matches the string "ABCDEF" after removing all not chars.

So in response I need to have only records 1,2,5

Upvotes: 0

Views: 32

Answers (1)

Nimer Awad
Nimer Awad

Reputation: 4199

If the query value has a space between ABC and DEF, then you can use the normal query but without using .keyword after the field name.

for example:

{
  "query": {
    "match": {
      "textField": "ABC DEF"
    }
  }
}

Upvotes: 1

Related Questions