【发布时间】:2013-12-03 13:54:26
【问题描述】:
我正在使用弹性搜索按类别页面上的某些条件过滤产品。 一种选择是按制造商过滤。用户可以选择制造商名称并获得过滤的结果集。我的问题是,虽然映射被定义为“not_analyzed”,但 elasticsearch 似乎对方面术语进行了标记。
请看下面的例子:
我的映射如下所示:
POST /products_test/product
{
"mappings" : {
"product":{
"properties":{
"manufacturer": {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}
这是我的测试数据:
POST /products_test/product/1
{
"id": 1,
"manufacturer": "bra"
}
POST /products_test/product/2
{
"id": 2,
"manufacturer": "abracada bra"
}
如果我执行以下查询,我会得到一个命中,但该方面有两个术语:
POST /products_test/_search
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"term": {
"manufacturer": "abracada"
}
}
}
},
"facets": {
"f_manufacturer": {
"terms": {
"field": "manufacturer",
"size": 30,
"order": "term",
"all_terms": false
}
}
}
}
结果:
"facets": {
"f_manufacturer": {
"_type": "terms",
"missing": 0,
"total": 2,
"other": 0,
"terms": [
{
"term": "abracada",
"count": 1
},
{
"term": "bra",
"count": 1
}
]
}
}
我的期望是获得一个以“abracada bra”为价值的单面术语。
【问题讨论】:
-
那里似乎没有问题。但是,我建议您检查两次映射。你可能会错过一些东西。
标签: elasticsearch faceted-search facet