Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit ff7f968

Browse files
DATASOLR-205 - Create Documentation for Pivot Faceting
documented use of pivot faceting.
1 parent 82626ed commit ff7f968

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/main/asciidoc/reference/misc.adoc

+43
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,49 @@ options.addFacetOnField(new FieldWithFacetParameters("name").setPrefix("spring")
7777
----
7878
====
7979

80+
[[solr.misc.faceting.pivot]]
81+
=== Pivot Faceting
82+
83+
Pivot faceting (Decision Tree) are also supported, and can be queried using `@Facet` annotation as follows:
84+
85+
====
86+
[soruce,java]
87+
----
88+
public interface {
89+
90+
@Facet(pivots = @Pivot({ "category", "dimension" }, pivotMinCount = 0))
91+
FacetPage<Product> findByTitle(String title, Pageable page);
92+
93+
@Facet(pivots = @Pivot({ "category", "dimension" }))
94+
FacetPage<Product> findByDescription(String description, Pageable page);
95+
96+
}
97+
----
98+
====
99+
100+
Alternatively it can be queried using `SolrTemplate` as follows:
101+
102+
====
103+
[source,java]
104+
----
105+
FacetQuery facetQuery = new SimpleFacetQuery(new SimpleStringCriteria("title:foo"));
106+
FacetOptions facetOptions = new FacetOptions();
107+
facetOptions.setFacetMinCount(0);
108+
facetOptions.addFacetOnPivot("category","dimension");
109+
facetQuery.setFacetOptions(facetOptions);
110+
FacetPage<Product> facetResult = solrTemplate.queryForFacetPage(facetQuery, Product.class);
111+
----
112+
====
113+
114+
In order to retrieve the pivot results the method `getPivot` can be used as follows:
115+
116+
====
117+
[source,java]
118+
----
119+
List<FacetPivotFieldEntry> pivot = facetResult.getPivot(new SimplePivotField("categories","available"));
120+
----
121+
====
122+
80123
[[solr.misc.terms]]
81124
== Terms
82125

0 commit comments

Comments
 (0)