Ibrahim Ali Khan
Ibrahim Ali Khan

Reputation: 92

Elastic search query syntax

I am trying to retrieve documents based on the following query:

POST _search
{
    "size": 1, 
    "filter": {
        "bool": {
            "must": [
               {
                   "range":{
                        "myfield": {
                            "from": "yyyy-mm-ddT00:00:00Z",
                            "to": "yyyy-mm-ddT00:00:00Z"
                        }
                    }
               },
                {"term": {"myfield1.myfield2" : "myvalue"}}
            ]
        }
    }
}

which doesnot return any result. There might be a problem with my syntax. I'd appreciate if anyone can help.

here is the structure of the document:

"_source": {
    "myfield": "yyyy-mm-ddT00:00:00",
    "myfield1": {
        "myfield2": "myvalue"
    }
}

Upvotes: 0

Views: 138

Answers (1)

Val
Val

Reputation: 217254

The field of the term query is not correct.

Instead of this:

{"term": {"myfield.myfield1.myfield2" : "myvalue"}}

Try this:

{"term": {"myfield1.myfield2" : "myvalue"}}

Upvotes: 1

Related Questions