Java API for Facet


(irbis) #1

I'm looking for Java API describing facet search, where can I see it?


(David Pilato) #2

I'm afraid there isn't.

But, it's really easy to use.

Just addFacet to your search using facet builder :
https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java
https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java#L321

https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/FacetBuilders.java

HTH,

David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Le 29 octobre 2011 à 01:29, Irbis alexeylevin1@gmail.com a écrit :

I'm looking for Java API describing facet search, where can I see it?


(irbis) #3

Hi David,
Thank you for the response.
I found how to run the facet search, but returns all the values for given
field name.
I want to search for specific value, for example, field name Type and value
"Car" so I want it returns counts for Car only

On Sat, Oct 29, 2011 at 2:10 AM, david@pilato.fr david@pilato.fr wrote:

**

I'm afraid there isn't.

But, it's really easy to use.

Just addFacet to your search using facet builder :

https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java

https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java#L321

https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java#L321

https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/FacetBuilders.java

HTH,

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Le 29 octobre 2011 à 01:29, Irbis alexeylevin1@gmail.com a écrit :

I'm looking for Java API describing facet search, where can I see it?


(Gustavo Maia) #4

Use regex for filter your facet

Enviado via iPhone

Em 28/10/2011, às 22:19, Alexey Levin alexeylevin1@gmail.com escreveu:

Hi David,
Thank you for the response.
I found how to run the facet search, but returns all the values for given field name.
I want to search for specific value, for example, field name Type and value "Car" so I want it returns counts for Car only

On Sat, Oct 29, 2011 at 2:10 AM, david@pilato.fr david@pilato.fr wrote:
I'm afraid there isn't.

But, it's really easy to use.

Just addFacet to your search using facet builder :
https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java
https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java#L321

https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/FacetBuilders.java

HTH,

David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Le 29 octobre 2011 à 01:29, Irbis alexeylevin1@gmail.com a écrit :

I'm looking for Java API describing facet search, where can I see it?


(Karussell) #5

Alexey,

faceted search is different to a normal search which also returns the
total count. If you want an optimized count search there is also the
count api:

http://www.elasticsearch.org/guide/reference/java-api/count.html

Peter.

On 29 Okt., 01:19, Alexey Levin alexeylev...@gmail.com wrote:

Hi David,
Thank you for the response.
I found how to run the facet search, but returns all the values for given
field name.
I want to search for specific value, for example, field name Type and value
"Car" so I want it returns counts for Car only

On Sat, Oct 29, 2011 at 2:10 AM, da...@pilato.fr da...@pilato.fr wrote:

**

I'm afraid there isn't.

But, it's really easy to use.

Just addFacet to your search using facet builder :

https://github.com/elasticsearch/elasticsearch/blob/master/modules/el...

https://github.com/elasticsearch/elasticsearch/blob/master/modules/el...

https://github.com/elasticsearch/elasticsearch/blob/master/modules/el...

https://github.com/elasticsearch/elasticsearch/blob/master/modules/el...

HTH,

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Le 29 octobre 2011 à 01:29, Irbis alexeylev...@gmail.com a écrit :

I'm looking for Java API describing facet search, where can I see it?


(Yang) #6

Dear all,

I'm playing with elastic search, it's pretty good.

But here I meet some problem on facet.

I tried to issue a search request with code like below:

SearchRequestBuilder srb = ...
//set query and other properties.
TermFacetBuilder facet = new TermFacetBuilder("tags");
facet.field("docs");

srb.addFacet(facet);

After I execute this search request, I can get a search response, when I print the response, I see all terms with count number, but I don't know how to get the count via java code, could anyone give me some resource?

Thanks very much~~~

Yang


(system) #7