Reputation: 7395
I am trying to retrieve data from ES using the search API.
The name of the index is index_certificate
and the document type is doc_certificate
.
Below API call works fine and returns results.
curl -X POST "http://elasticsearch:9200/index_certificate/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"must": [
{
"match": {
"district_id": {
"query": "10"
}
}
}
]
}
}
}'
But if I add the document type to the url without changing any other thing as below, it returns an empty result array. (Does not throw any errors)
curl -X POST "http://elasticsearch:9200/index_certificate/doc_certificate/_search?pretty" -H 'Content-Type: application/json' -d' { "query": { "bool": { "must": [ { "match": { "district_id": { "query": "10" } } } ] } } }'
I am not the one who did setup the node. Also this is not a production node. I am not sure whether this can be due to a read/write permission issue related to the document. I appreciate if someone can help me to solve this. Thank you.
Upvotes: 0
Views: 333
Reputation: 217254
As you can see the _type
of your documents is _doc
and not doc_certificate
So the following would work:
curl -X POST "http://elasticsearch:9200/index_certificate/_doc/_search?pretty" -H 'Content-Type: application/json' -d' { "query": { "bool": { "must": [ { "match": { "district_id": { "query": "10" } } } ] } } }'
Upvotes: 2