Let's inject some data in Elasticsearch
curl -XPUT 'localhost:9200/customer/external/1' -d '{ "author": "John", "published_from":"2016-08-03" }'
curl -XPUT 'localhost:9200/customer/external/2' -d '{ "author": "Jeanne", "published_from":"2016-08-03" }'
curl -XPUT 'localhost:9200/customer/external/3' -d '{ "author": "Jean", "published_from":"2016-08-05" }'
I am trying to query document with published_from=2016-08-03 and author=John. I try to do it with this curl command:
curl -g "localhost:9200/customer/external/_search?pretty&filter_path=hits.hits._source.author&q=+author:John+published_from:2016-08-03"
Yet, the output displays Jeanne
{
"hits" : {
"hits" : [
{
"_source" : {
"author" : "John"
}
},
{
"_source" : {
"author" : "Jeanne"
}
}
]
}
}
When I try this curl command :
curl "localhost:9200/customer/external/_search?pretty&filter_path=hits.hits._source.author&q=%2Bauthor%3AJohn+%2Bpublished_from%3A2016-08-03"
The output is exactly what I want.
{
"hits" : {
"hits" : [
{
"_source" : {
"author" : "John"
}
}
]
}
}
Why is the first command not working as expected ?