【发布时间】:2014-07-14 16:32:36
【问题描述】:
我使用的是弹性搜索 1.2.1 版
该属性的存储值是shoes,该字段的分析器是雪球,尽管如此,当我搜索shoes 时,ES 还是找不到它。当我搜索 shoe 时,它会找到文档...
这是我的查询:
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"or": [
{
"term": {
"category": "shoes"
}
},
{
"term": {
"sub_category1": "shoes"
}
},
{
"term": {
"sub_category2": "shoes"
}
},
{
"term": {
"brand": "shoes"
}
},
{
"term": {
"shop": "shoes"
}
}
]
}
}
},
"aggregations": {
"category": {
"terms": {
"field": "category"
}
},
"sub_category1": {
"terms": {
"field": "sub_category1"
},
"aggregations": {
"discount": {
"avg": {
"field": "discount_percentage"
}
}
}
}
}
}
这是我的映射:
"mappings": {
"item": {
"properties": {
"brand": {
"type": "string",
"analyzer": "snowball"
},
"category": {
"type": "string",
"analyzer": "snowball"
},
"color": {
"type": "string"
},
"created_at": {
"type": "date",
"format": "dateOptionalTime"
},
"discount_percentage": {
"type": "long"
},
"domain_name": {
"type": "string"
},
"id": {
"type": "long"
},
"image": {
"type": "string"
},
"item_name": {
"type": "string"
},
"link": {
"type": "string"
},
"need_indexing": {
"type": "boolean"
},
"price": {
"type": "string"
},
"price_range": {
"type": "string"
},
"product_key": {
"type": "string"
},
"raw_size": {
"type": "string"
},
"regular_price": {
"type": "string"
},
"sale_price": {
"type": "string"
},
"scrape_run": {
"type": "string"
},
"shop": {
"type": "string",
"analyzer": "snowball"
},
"size": {
"type": "string"
},
"source_url": {
"type": "string"
},
"sub_category1": {
"type": "string",
"analyzer": "snowball"
},
"sub_category2": {
"type": "string",
"analyzer": "snowball"
},
"updated_at": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}
【问题讨论】: