[英]Meilisearch - what's the differences & relationship among: searchableAttributes, filterableAttributes, faceting
searchableAttributes
, filterableAttributes
, faceting
. searchableAttributes
, filterableAttributes
, faceting
。 I've read the documents, but a bit confused.我读过文件,但有点困惑。
Please give some insights about:请提供一些见解:
searchableAttributes
are attributes where Meilisearch can search in for matching query words. searchableAttributes
是美丽搜索可以搜索匹配查询词的属性。filterableAttributes
are a list of attributes that can be used as filters to refine the search results. filterableAttributes
是一个属性列表,可以用作筛选器来优化搜索结果。 Given a movies dataset, if you want to filter movies by release_date
, you need to first add the attribute release_date
to the filterableAttributes
list.release_date
过滤电影,你需要先将属性release_date
添加到filterableAttributes
列表中。 Both searchableAttributes
and filterableAttributes
are part of Meilisearch settings. searchableAttributes
和filterableAttributes
都是美丽搜索设置的一部分。 An attribute doesn't necessarily have to be searchable for it to be filterable, so no relation between both.一个属性不一定必须是可搜索的才能被过滤,所以两者之间没有关系。
facets
is a search parameter, not a setting, it must be added to a search request. facets
是搜索参数,不是设置,必须添加到搜索请求中。 It gives information about the number of documents found per attribute value.它提供有关每个属性值找到的文档数的信息。 If you want to know how many movies there are per genre for a given query, you can pass the
"facets": ["genres"]
as a parameter in the search query like so:如果您想知道给定查询的每个流派有多少部电影,您可以将
"facets": ["genres"]
作为搜索查询中的参数传递,如下所示:
curl \ -X POST 'http://localhost:7700/indexes/movies/search' \ -H 'Content-Type: application/json' \ --data-binary '{ "q": "Batman", "facets": ["genres"] }'
The response should include a facetDistribution
object with the information:响应应包含一个
facetDistribution
object,其中包含以下信息:
{
"hits": [
…
],
…
"facetDistribution": {
"genres": {
"action": 273,
"animation": 118,
"adventure": 132,
"fantasy": 67,
"comedy": 475,
"mystery": 70,
"thriller": 217
}
}
}
In order to have the facets information about an attribute, it must be first present in the filterableAttributes
list.为了获得关于属性的方面信息,它必须首先出现在
filterableAttributes
列表中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.