0
votes

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

1
Your sellerId field is probably an analyzed string and hence the value has been analyzed and tokenized. Can you show what you get when running: curl -XGET localhost:9200/your_index ?Val
@Val I get a mapping of all my field and for this particular field, I get: this: "sellerId": { "type": "string" },Arfeen

1 Answers

1
votes

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.