Query seach in elasticsearch

I'm trying to search in elasticsearch by query.
I'm want to get uuid = 002A13AC-93E6-4141-AA28-0A86F1B5E5C2 of device index.
GET device/_search?
{
"query": {
"match": {
"uuid" : "0aaa02A13AC-93E6-4141-AA28-0A86F1B5E5C2"
}
}
}

I want to get exactly the uuid. Only one letter difference is not effective. match is wrong.
Any help on how to resolve this issue? Sorry for my english.

Just to be clear, you want it to match both 002A13AC-93E6-4141-AA28-0A86F1B5E5C2 and 0aaa02A13AC-93E6-4141-AA28-0A86F1B5E5C2?

sorry. I'm just want to get uuid = 002A13AC-93E6-4141-AA28-0A86F1B5E5C2 in my query.
If use match, in the query uuid = 0aaa02A13AC-93E6-4141-AA28-0A86F1B5E5C2, the result will still return 002A13AC-93E6-4141-AA28-0A86F1B5E5C2.

This is due to how your field is mapped. If you have not specified any index template it may be using the default mapping. In that case try to query uuid.keyword instead using a term query as that is not analyzed.

2 Likes

Thanks very much. Can you help me get the uuid list in divice index

Try something like this (have not tested) assuming you are using default mappings:

GET device/_search?
{
  "query": {
    "term": {
      "uuid.keyword": {
        "value": "002A13AC-93E6-4141-AA28-0A86F1B5E5C2"
      }
    }
  }
}

The documentation contains further details.

thanks you very much.

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