If you want two queries to return the same results, you need to use the same type of query. In a Sense request, you execute a compliance request:
"query": { "match" : { "name" : "some string" } }
but in your java code you execute termQuery:
QueryBuilder qb = QueryBuilders.termQuery("name", "some string");
So, to answer your question, use the matching code in your Java code instead:
QueryBuilder qb = QueryBuilders.matchQuery("name", "some string");
As for your second question, it is a bit broad. I would of course try to go through the documentation and search here in StackOverflow. Regarding the Java API, I would look here for a review and here for information on the dsl thru Java query.
I think a good general understanding of how Elasticsearch works and some comfort with a request mechanism through the REST API will be very useful for understanding the Java API. Good places to start:
http://joelabrahamsson.com/elasticsearch-101/
http://exploringelasticsearch.com/
http://java.dzone.com/articles/elasticsearch-getting-started
John petrone
source share