Hi,
Thanks for both replies.
Yep. I agree it was not a query. Where can I find what are possible values
in Query DSL - like the one you mentioned “match_phrase”.
While we are at it I have another question - In production probably it is
better to get from user a search string and pass it as is (like “(Cisco AND
Network) OR Firewall”) to the code like this:
String search = “(Cisco AND Network)
SearchRequestBuilder srb = client.prepareSearch("asset_index").setTypes(
"Asset").setSearchType(SearchType.DEFAULT);
srb.setQuery(QueryBuilders.queryString(search));
… and let the elasticsearch to do the job for you? Would you agree?
Regards,
Janusz
On Wednesday, 16 January 2013 16:06:59 UTC+11, JD wrote:
Hi,
I have a search string that is already JSON string like this:
{
description:"Cisco Network Data Switch"
}
When I pass it to the code below :
SearchRequestBuilder srb =
client.prepareSearch("asset_index").setTypes("Asset").setSearchType(
SearchType.DEFAULT).setQuery(search);
SearchResponse response = srb.execute().actionGet();
... I get :
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to
execute phase [query], total failure; shardFailures
{[PdwFM8JUTjqVbZqPEdOT0w][asset_index][0]:
SearchParseException[[asset_index][0]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"query_binary":"ewoJZGVzY3JpcHRpb246IkNpc2NvIE5ldHdvcmsgRGF0YSBTd2l0Y2giCn0="}]]];
nested: QueryParsingException[[asset_index] [_na] query malformed, no field
after start_object]; }{[PdwFM8JUTjqVbZqPEdOT0w][asset_index][4]:
SearchParseException[[asset_index][4]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"query_binary":"ewoJZGVzY3JpcHRpb246IkNpc2NvIE5ldHdvcmsgRGF0YSBTd2l0Y2giCn0="}]]];
nested: QueryParsingException[[asset_index] [_na] query malformed, no field
after start_object]; }{[PdwFM8JUTjqVbZqPEdOT0w][asset_index][1]:
SearchParseException[[asset_index][1]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"query_binary":"ewoJZGVzY3JpcHRpb246IkNpc2NvIE5ldHdvcmsgRGF0YSBTd2l0Y2giCn0="}]]];
nested: QueryParsingException[[asset_index] [_na] query malformed, no field
after start_object]; }{[PdwFM8JUTjqVbZqPEdOT0w][asset_index][3]:
SearchParseException[[asset_index][3]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"query_binary":"ewoJZGVzY3JpcHRpb246IkNpc2NvIE5ldHdvcmsgRGF0YSBTd2l0Y2giCn0="}]]];
nested: QueryParsingException[[asset_index] [_na] query malformed, no field
after start_object]; }Regards,
Janusz
--