enp
(Eugene Prokopiev)
May 25, 2016, 11:54am
1
Hi,
Is it possible to search by ids and term both? I tried to do something like:
curl -XGET 'http://localhost:9200/hotels/hotel/_search' -d ' { "query" : { "ids" : { "values" : [ "c900640a-12e5-4f02-8fec-07f6f4bf58ab", "56d46e68-07e8-4502-be08-df68730bae67" ] }, "term" : { "type" : "couple" } } } '
but result was:
# ERROR: Search::Elasticsearch::Error::Request [http://localhost:9200]-[400] [parse_exception] failed to parse search source. expected field name but got [START_OBJECT]
Query by ids or term only works fine
warkolm
(Mark Walkom)
May 26, 2016, 12:10am
2
Are you essentially stating these should be an OR, or are you doing some filtering?
NgocPham
(Ngọc Phạm)
May 26, 2016, 4:13am
3
i try with java and it work together.
here is code i tried
SearchResponse response =
this.client
.prepareSearch("hotels")
.setQuery(
QueryBuilders.boolQuery().should(QueryBuilders.idsQuery("c900640a-12e5-4f02-8fec-07f6f4bf58ab"))
.should(QueryBuilders.termQuery("type", "couple"))).setSize(10000).execute().actionGet();
Im not sure how to code by CURL, i will try and comment if i find it later
Here is code it auto convert from java to query curl, but i think have something wrong :))
{
"bool" : {
"should" : [ {
"ids" : {
"type" : "c900640a-12e5-4f02-8fec-07f6f4bf58ab",
"values" : [ ]
}
}, {
"term" : {
"type" : "couple"
}
} ]
}
}
enp
(Eugene Prokopiev)
May 26, 2016, 4:48am
4
I need to filter by ids AND term
enp
(Eugene Prokopiev)
May 26, 2016, 4:54am
5
It looks like second 'should' call rewrites first 'should' call. I tried to do the same in perl clent, but with:
query => { bool => { should => { ids => { values => $ids }}, should => { term => { "type" => "couple" }}}}
I got:
"query" : {
"bool" : {
"should" : {
"term" : {
"type" : "couple"
}
}
}
}