I am using
SearchBuilder.searchSource.query(query_string).buildAsBytes()
to perform the query string on elasticsearch servers.
The problem is that I dont know what is the correct format of query string. For instance, I want to find all documents with country field to be US, I can use the restful api of
http://my.elastic.search.server/foo/dummy/_search?q=country:US
to get what I need. But in terms of java api, I tried country:US, q=country:US, and {\"country\":\"US\"}, but each time I got back SearchPhaseExecutionException.
ElasticSearch’s documentation does not shed any lights on what could be the format of query string in this case, and I have exhausted Google results related to this topic. Can someone help me on this? Thanks!
OK. seems like I need to pass in a more contrived json string
{
“query_string” : {
“default_field”: “anotherFoo”,
“query”: “this AND that OR there”
}
}
It is useful in that I can pass in pure Lucene-style query against elasticsearch.