I
I
iamsaint2014-09-19 12:32:04
elasticsearch
iamsaint, 2014-09-19 12:32:04

elasticsearch. . How to do a search on a field that contains a hyphen?

Good afternoon.
My question is in the title. Example of a field to search for a record: '1111-2222-3333-4444'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MintTea, 2015-01-15
@MintTea

GDRP5MbKvBE.jpg
If you are interested in an analogue of such a request:
Then you must first set the mapping for this field:

curl -XPUT 'http://localhost:9200/index_name/type_name/_mapping' -d '
{
    "properties" : {
        "field_name" : {"type": "string", "index": "not_analyzed"}
    }
}
'

After that, records can be found using the "term" filter:
curl -XGET 'http://localhost:9200/index_name/type_name/_search?pretty' -d '{
    "filter": {
        "term": {
            "field_name": "1111-2222-3333-4444"
        }
    }
}'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question