Daniel Moses
Daniel Moses

Reputation: 5858

Does spring-data-solr have a way to provide json.facet parameter?

As far as I can tell there is not a way to provide a facet.json to using spring-data-solr.

What I would like is something like this:

public interface FooRepository extends SolrCrudRepository<Foo, Long> {
    @Query(value = "name:?0")
    @Facet(json="{More complex facet JSON here}")
    FacetPage<Foo> findByNameAndFacet(String name, Pageable page);
}

Even then, I don't think the facets that come back would fit nicely into the FacetPage object.

What's the best way to handle this in an application that already has spring-data-solr? My current option is to just use SolrClient seperatly from my spring-data-solr repositories.

PS - The reason why I'm interested in doing json.facet is for both aggregate functions avg and field/ranges with domain that exclude tags similar to http://yonik.com/multi-select-faceting/

Upvotes: 1

Views: 630

Answers (1)

aakath
aakath

Reputation: 106

If you can manage with field facets, to exclude a tagged filter, you could do something like:

public interface FooRepository extends SolrCrudRepository<Foo, Long> { @Query(value = "name:?0", filters = { "{!tag=COLOR}color:?1" }) @Facet(fields = { "{!ex=COLOR key=colors}color" }) FacetPage<Foo> findByNameAndColorFacet(String name, String color, Pageable page); }

Upvotes: 2

Related Questions