I am new to ES and trying to implement faceted navigation in the same way as most major e-commerce stores.
Part of my product mapping is as follows:
'name' => [
'type' => 'string',
'analyzer' => 'english_analyzer',
],
'range' => [
'type' => 'string',
'analyzer' => 'english_analyzer',
],
'filters' => [
'type' => 'nested',
'properties' => [
'name' => [
'type' => 'string',
'index' => 'not_analyzed',
],
'values' => [
'type' => 'object',
'properties' => [
'name' => [
'type' => 'string',
'index' => 'not_analyzed',
]
]
]
]
],
As you can see, I save the facets in the "filters" as a nested object.
In my search query, I can add this aggregation to my query:
'aggs' => [
'facets' => [
'nested' => ['path' => 'filters'],
'aggs' => [
'filters' => [
'terms' => [
'field' => 'filters.name',
'size' => 0
],
'aggs' => [
'id' => [
'terms' => [
'field' => 'filters.id'
]
],
'values' => [
'terms' => [
'field' => 'filters.values.name',
'size' => 0
],
'aggs' => [
'id' => [
'terms' => [
'field' => 'filters.values.id'
]
]
]
]
]
]
]
]
]
This gives me a good list of facets that can be used in my navigation. I can apply the selected faces to the results of my document in two ways: using the "filter by mail" or "filtered request"
post , . , , .
- - 2. , , , .
:
:
Brands:
- , , .
:
ElasticSearch:
, , ( ) . , (https://www.elastic.co/guide/en/elasticsearch/guide/current/_filter_bucket.html) . bool, , , , .
, , / , , bool, . , , , , !
, , , , . ?
, , .