Eri*_*ang 0 full-text-search meilisearch
searchableAttributes, filterableAttributes, faceting. 我读过这些文件,但有点困惑。
请提供一些有关以下方面的见解:
小智 5
searchableAttributes是 Meilisearch 可以搜索匹配查询词的属性。filterableAttributes是可用作筛选器以细化搜索结果的属性列表。给定一个电影数据集,如果您想按 过滤电影release_date,您需要首先将该属性添加release_date到filterableAttributes列表中。和searchableAttributes都是filterableAttributes美丽搜索设置的一部分。属性不一定要可搜索才能可过滤,因此两者之间没有关系。
facets是搜索参数,而不是设置,必须将其添加到搜索请求中。它提供有关每个属性值找到的文档数量的信息。如果您想知道给定查询的每种类型有多少部电影,您可以将"facets": ["genres"]作为参数传递到搜索查询中,如下所示:
curl \\\n-X POST 'http://localhost:7700/indexes/movies/search' \\\n-H 'Content-Type: application/json' \\\n--data-binary '{\n "q": "Batman",\n "facets": ["genres"]\n}'\nRun Code Online (Sandbox Code Playgroud)\n响应应包含一个facetDistribution包含以下信息的对象:
{\n "hits": [\n \xe2\x80\xa6\n ],\n \xe2\x80\xa6\n "facetDistribution": {\n "genres": {\n "action": 273,\n "animation": 118,\n "adventure": 132,\n "fantasy": 67,\n "comedy": 475,\n "mystery": 70,\n "thriller": 217\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n为了获得有关属性的方面信息,它必须首先出现在列表中filterableAttributes。