FacetDefinition
- fieldType: string · Fieldrequired
The field name to create a facet against. For example, the following query will create a facet against the
custom_attributes.directorfield, and return the ten most common facet values of this field (for Products that match the search query):{ "field": "custom_attributes.director", "size": 10 } - aliasType: string · Alias
The
aliasparameter gives a unique name to a facet, especially useful when you have multiple facets on the same field.By default, facet results use the
fieldas the key. But with multiple facets on one field, this can get confusing.aliassolves this:{ "field": "custom_attributes.director", "alias": "director_facet", "size": 10 }In the response, you'll see results under the key
director_facetinstead of the field name. - excludeType: string · Exclude
The
excludeparameter filters out facet values using a regular expression. For example:{ "field": "custom_attributes.director", "size": 10, "exclude": "Steven.*" }This will omit all facet values starting with "Steven" (case-sensitive).
To exclude values with special characters, use a backslash
\or double quotes:{ "field": "custom_attributes.place_name", "size": 10, "exclude": "\"St.\".*" }This excludes facet values starting with "St.".
Remember,
excludeonly affects facet values, not the search results themselves. - includeType: string · Include
Filter facet values based on a regular expression. For example, the following query will return only the facet values that start with
Steven(case-sensitive):{ "field": "custom_attributes.director", "size": 10, "include": "Steven.*" }You can escape a special character with a preceding backslash
\or surround it with double quotes. For example, the following query will only return the facet values starting withSt.:{ "field": "custom_attributes.place_name", "size": 10, "include": "\"St.\".*" }Note that, the
includeparameter will only affect the facet values, and will not affect the search result itself. - queriesType: array object[] · Queries
Facet queries that support facet counts for any arbitrary Lucene queries, each of which is labeled by a user-friendly "key":
{ "field": "my_custom_facet", "queries": [ { "query": "price: [* TO 10] AND size:"Small"", "key": "Less than 10 dollars / Small size" }, { "query": "price: [10 TO 100] AND size:"Medium"", "key": "10 to 100 dollars / Medium size" }, { "query": "price: [100 TO *] AND size:"Large"", "key": "More than 100 dollars / Large size" } ] }In the response, Miso refers to the query result by their
key. For example, the above request will have the following response:{ "facet_counts": { "facet_fields": { "my_custom_facet": [ [ "Less than 10 dollars / Small size", 1987 ], [ "10 to 100 dollars / Medium size", 109 ], [ "More than 100 dollars / Large size", 123 ] ] } } }- keyType: string · Keyrequired
User friendly label of the query result
- queryType: string · Queryrequired
Query in Lucene syntax
- rangesType: array object[] · Ranges
Facet ranges for numeric fields or date-like string fields. For example, the following query groups the products into fours buckets against on their
original_priceranges, each of which has a user-friendly "key":{ "field": "original_price", "ranges": [ {"to": 10, "key": "Less than 10 dollars"}, {"from": 10, "to": 100, "key": "10 to 100 dollars"}, {"from": 100, "to": 1000, "key": "100 to 1,000 dollars"}, {"from": 1000, "key": "More than 1,000 dollars"} ] }For each range object, you need to at least specify one of the
toorfromvalues (or both).fromis always inclusive, andtois always exclusive. In the response, Miso refers to each bucket by theirkey. For example, the above request will have the following response:{ "facet_counts": { "facet_fields": { "original_price": [ [ "Less than 10 dollars", 1987 ], [ "10 to 100 dollars", 109 ], [ "100 to 1,000 dollars", 123 ], [ "More than 1,000 dollars", 5 ] ] } } }- keyType: string · Keyrequired
User friendly label of the range
- from
Start of the range (inclusive).
- Type: string · From
Start of the range (inclusive).
- to
End of the range (exclusive).
- Type: string · To
End of the range (exclusive).
- sizeType: integer · Size
Number of facet values to return. The facet values are sort descendingly by the number of Products that have these values (and match the search query).
