2

I am relatively new to Elasticsearch. I am storing records in my ES index using the following POST request on Postman

http://localhost:9200/boqss/_doc/6
{
    "projectId" : "KLMN",
    "boqList" : [ 
       {

            "particulars" : "Providing & Casting R.C.C M25",
            "quantity" : 900,
            "unit" : "m3",
            "rate" : 8000,
            "amount" : 7200000
        }
        ]

}

When I perform a search query like this

http://localhost:9200/boqss/_search

I get the following response :

"hits": [
            {
                "_index": "boqss",
                "_type": "_doc",
                "_id": "1",
                "_score": 1.0,
                "_source": {
                    "projectId": "ABCD",
                    "boqList": [
                        {
                            "particulars": "Excavation ",
                            "quantity": 1500,
                            "unit": "m3",
                            "rate": 500,
                            "amount": 750000
                        }
                    ]
                }
            },
            {
                "_index": "boqss",
                "_type": "_doc",
                "_id": "2",
                "_score": 1.0,
                "_source": {
                    "projectId": "ABCD",
                    "boqList": [
                        {
                            "particulars": "Providing & laying Rubble Soling",
                            "quantity": 300,
                            "unit": "m2",
                            "rate": 450,
                            "amount": 135000
                        }
                    ]
                }
            },

           ...

However, when I perform another search query like the following :


http://localhost:9200/boqss/_search
{
      "query":{
      "match" : {
         "particulars":"Excavation"
      }
   }
}

I get zero hits with a response as follows :


{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 0,
            "relation": "eq"
        },
        "max_score": null,
        "hits": []
    }
}

How can I make sure that I retrieve the 'Excavation' entry? Any help would be greatly appreciated. Thank you!

1 Answer 1

3

Good start!! You just need to use the fully-qualified field name boqList.particulars:

{
      "query":{
      "match" : {
         "boqList.particulars":"Excavation"
      }
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.