Arfeen
Arfeen

Reputation: 2623

Elasticsearch not searching a field in term query

I'm having a problem in searching records with a field. Although, field exists with the value in the document in Elasticsearch but when I use this field to search as term, it does not fetch the record. Other fields are doing great.

JSON Request:

{
  "query": {
    "filtered": {
      "query": {
        "match_all": [

        ]
      },
      "filter": {
        "and": [
          {
            "term": {
              "sellerId": "6dd7035e-1d6f-4ddb-82f4-521902bfc29e"
            }
          }
        ]
      }
    }
  }
}

It does not return any error, it just doesn't fetch the related document. I tried searching with other fields and they worked fine.

Is there anything I'm missing here ?

Elasticsearch version: 2.2.2

Arfeen

Upvotes: 0

Views: 1254

Answers (1)

Val
Val

Reputation: 217274

You need to reindex your data and change the mapping of that field to

 "sellerId": { 
   "type": "string",
   "index": "not_analyzed"
 }

That way the UUID won't be analyzed and split into tokens and you'll be able to search it using a term query.

Upvotes: 1

Related Questions