A
A
alexpy52020-06-01 11:42:13
elasticsearch
alexpy5, 2020-06-01 11:42:13

How to do regular expression search in Elasticsearch?

Does not search by regular expressions in Elasticsearch

Index: items
Field: lot_description
Regular expression: Pan.sonic I execute


the following query in the console:

curl -XPOST 'localhost:9200/items/_search' -H 'Content-Type: application/json' 
-d '{"query": 
    {"regexp": 
        {"lot_description": 
            {"value": "Pan.sonic"}}}}'


Result:

{"took":8,"timed_out":false,"_shards":
    {"total":1,"successful":1,"skipped":0,"failed":0},
    "hits":
        {"total":{"value":0,"relation":"eq"},
    "max_score":null,"hits":[]}}


Finds nothing. But such lines do exist.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexpy5, 2020-06-03
@alexpy5

Found a way to make it work. If there are letters in the regular expression, then they must be in lower case, then it works.
Why this happens is not clear, I did not find it in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question