Add attributesToRetrieve for facetDistribution #758
Replies: 2 comments 1 reply
-
Hello @mmmcorpsvit , I'm not sure if I understand your need correctly. Facets are a way of categorizing documents and facet search will return the number (count) of documents that match those categories. What other fields could be returned in a set of facets? Do you mean you'd like to return some of the document fields from the documents that match the facets as well? |
Beta Was this translation helpful? Give feedback.
-
for example i have cars (id + name) and attribute color (id + name)
if i need get facet with count - meilisearch only propose way: facet by color_name, but color name is not unique same on elasticksearch have this important future: POST /cars2/_search
{
"size": 0,
"aggs": {
"colors": {
"terms": {
"field": "color.id"
},
"aggs": {
"color_details": {
"top_hits": {
"_source": {
"includes": ["color.id", "color.name"]
},
"size": 1
}
}
}
}
}
} {
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 5,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"colors": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 1,
"doc_count": 2,
"color_details": {
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "cars2",
"_id": "1",
"_score": 1,
"_source": {
"color": {
"id": 1,
"name": "Red"
}
}
}
]
}
}
},
{
"key": 2,
"doc_count": 2,
"color_details": {
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "cars2",
"_id": "2",
"_score": 1,
"_source": {
"color": {
"id": 2,
"name": "Blue"
}
}
}
]
}
}
},
{
"key": 3,
"doc_count": 1,
"color_details": {
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "cars2",
"_id": "4",
"_score": 1,
"_source": {
"color": {
"id": 3,
"name": "Green"
}
}
}
]
}
}
}
]
}
}
} |
Beta Was this translation helpful? Give feedback.
-
how get count, and additionally: "name", "name_ua"?
https://blog.meilisearch.com/id-based-facets-guide/ - only one way - merge id and data, but this very ugly idea - because very slow)
Please add support to get count and another field, this critically important for e-shops to reduce queries to only one for get full facet information (count, names, something else...)
Beta Was this translation helpful? Give feedback.
All reactions