Method: Scrivito::ObjSearchEnumerator#facet
- Defined in:
- app/cms/scrivito/obj_search_enumerator.rb
#facet(attribute, options = {}) ⇒ Array<Scrivito::ObjFacetValue> #facet(facets) ⇒ Hash
Perform a faceted search over up to ten attributes to retrieve structured results for individual values of these attributes.
Applicable to attributes of the following types: string
, stringlist
, enum
, multienum
.
Please note that there is a precision limit for faceting: Only the first 50 characters of a string are guaranteed to be considered for faceting. If two string values have the same first 50 characters, they may be grouped into the same facet value.
Please note that by default #facet does not preload the first batch of the search results. In order to reduce the number of search requests, batch_size
can be explicitly set using the #batch_size method. This causes Scrivito to preload the first batch of the search results.
621 622 623 624 625 626 627 628 629 630 631 |
# File 'app/cms/scrivito/obj_search_enumerator.rb', line 621 def facet(*facet_params) search_params = search_dsl_params search_params[:size] = 0 unless @preload_batch facet_query = FacetQuery.new(facet_params, search_params, workspace) facet_query.execute! @preloaded_batch = facet_query.batch if @preload_batch facet_query.result end |