Help with JestClient equivalent of Elasticsearch java api query - how to add searchtype and facetbuilder

Hi,

I am having trouble translating following ElasticSearch NodeClient query
to JestClient. I have something along the lines of

SearchResponse sr = client.prepareSearch("myindex")
.setTypes("myproducts")
.setSearchType(SearchType.COUNT)
.setQuery(QueryBuilders.matchAllQuery())
.addFacet(FacetBuilders.termsFacet("facetname").field("someattr"))
.execute().actionGet();

I know how to set index, type and query but am stuck at searchtype, facet.

Would it be ok to create a SearchRequestBuilder with null client and pass
it the TermQueryBuilder and FacetBuilder and then convert the query to
string and pass it to JestClient (Search.createQuueryWithBuilders)?

thanks,
mihir

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I have replied through other channels but maybe others can use this
solution;

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchAllQuery());
searchSourceBuilder.facet(FacetBuilders.termsFacet("tag").field("tag").size(10)).facet(FacetBuilders.termsFacet("user").field("user").size(10));
String query = searchSourceBuilder.toString();

Search search = new Search(query);
search.addIndex("terms_facet");
search.addType("document");
JestResult result = client.execute(search);
List termsFacets = result.getFacets(TermsFacet.class);

On Sunday, March 10, 2013 8:20:03 AM UTC+2, Mihir M wrote:

Hi,

I am having trouble translating following Elasticsearch NodeClient query
to JestClient. I have something along the lines of

SearchResponse sr = client.prepareSearch("myindex")
.setTypes("myproducts")
.setSearchType(SearchType.COUNT)
.setQuery(QueryBuilders.matchAllQuery())
.addFacet(FacetBuilders.termsFacet("facetname").field("someattr"))
.execute().actionGet();

I know how to set index, type and query but am stuck at searchtype, facet.

Would it be ok to create a SearchRequestBuilder with null client and pass
it the TermQueryBuilder and FacetBuilder and then convert the query to
string and pass it to JestClient (Search.createQuueryWithBuilders)?

thanks,
mihir

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.