TermsFacetBuilder for Search using java Cleint

Hi,

M looking for any working example or suggestion as how to use terms
facet under search for java client.

I need to convert following REST Query to corresponding Java Client
Call.

{
"size" : 1,
"query" : {
"term" : {
"nto" : "627331749"
}
},
"facets": {
"tag": {
"terms" : {
"field": "ncontent.cnt.gid",
"size": 5
},
"filter" : {
"term" : {
"nuid" : "627331749"
}
}
}
}
}

I have managed with following , now need to integrate terms facet
builder with rest of code

SearchResponse response =
notifyDataStrucAbstract.elasticSearchClient.prepareSearch(ConfigList.getString("elasticSearchDbName"))
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(termQuery("nto" , uid))
.setFrom(0).setSize(60).setExplain(true)
.addFacet(facet)
.execute()
.actionGet();

Any kind of input will be appreciated

The FacetBuilders allow you to construct facets that can be added to the
addFacet method. Note that in the latest REST interface, a filter for a
facet is now called facet_filter.

    SearchResponse searchResponse = client.prepareSearch()
            .setSize(0)
            .setQuery(termQuery("stag", "111"))

.addFacet(FacetBuilders.termsFacet("facet1").field("stag").size(10))
.execute().actionGet();

-shay.banon

On Thu, Sep 9, 2010 at 12:33 PM, yogeshronly4u@gmail.com <
yogeshronly4u@gmail.com> wrote:

Hi,

M looking for any working example or suggestion as how to use terms
facet under search for java client.

I need to convert following REST Query to corresponding Java Client
Call.

{
"size" : 1,
"query" : {
"term" : {
"nto" : "627331749"
}
},
"facets": {
"tag": {
"terms" : {
"field": "ncontent.cnt.gid",
"size": 5
},
"filter" : {
"term" : {
"nuid" : "627331749"
}
}
}
}
}

I have managed with following , now need to integrate terms facet
builder with rest of code

SearchResponse response =

notifyDataStrucAbstract.elasticSearchClient.prepareSearch(ConfigList.getString("elasticSearchDbName"))

.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(termQuery("nto" , uid))
.setFrom(0).setSize(60).setExplain(true)
.addFacet(facet)
.execute()
.actionGet();

Any kind of input will be appreciated

Thnx Shay , that helped.

I understand ppl concentrating more on getting gr8 app like ES to
higher excellence n i congratulate whole team for the same, only thing
we need to address now is on full scale documentation and working
examples for bigger developer audience.

Looking forward for more treats from ES, Cheers :wink: