【发布时间】:2015-12-31 09:03:52
【问题描述】:
我正在 Elasticsearch 中为英国地址构建地址匹配引擎,我发现 shingles 非常有用,但是在标点符号方面我发现了一些问题。 “4 Walmley Close”的查询返回以下匹配项:
- 3 和 4 单元,Walmley Chambers,3 Walmley Close
- Flat 4, Walmley Court, 10 Walmley Close
- Co-Operative Retail Services Ltd, 4 Walmley Close
真正的匹配是 3 号,但是 1 和 2 都匹配(错误地),因为它们在变成带状疱疹时都变成了“4 walmley”。我想告诉 shingle 分析器不要生成跨越逗号的 shingles。因此,例如 1) 目前我得到:
- 单元 3
- 3 和
- 和4
- 4 沃姆利
- 沃姆利室
- 分庭 3
- 3 沃姆利
- walmley 关闭
...实际上我想要的只是....
- 单元 3
- 3 和
- 和4
- 沃姆利室
- 3 沃姆利
- walmley 关闭
我当前的设置如下。我已经尝试将标记器从标准转换为空白,这有助于它保留逗号并可能避免上述情况(即我最终以 '4, walmley' 作为地址 1 和 2 中的带状疱疹)但是我结束了在我的索引中有很多不可用的 shingles 并且有 7000 万个文档,我需要减小索引大小。
正如您在索引设置中看到的那样,我还有一个 street_sym 过滤器,我希望能够在我的带状疱疹中使用它,例如对于这个例子,除了生成“walmley close”之外,我还想要“walmley cl”,但是当我尝试包含这个时,我得到了“close cl”的带状疱疹,这并不是很有帮助!
非常感谢更有经验的 Elasticsearch 用户的任何建议。我已经阅读了 Gormley 和 Tong 的优秀书籍,但无法理解这个特定的问题。
提前感谢您提供的任何帮助。
"analysis": {
"filter": {
"shingle": {
"type": "shingle",
"output_unigrams": false
},
"street_sym": {
"type": "synonym",
"synonyms": [
"st => street",
"rd => road",
"ave => avenue",
"ct => court",
"ln => lane",
"terr => terrace",
"cir => circle",
"hwy => highway",
"pkwy => parkway",
"cl => close",
"blvd => boulevard",
"dr => drive",
"ste => suite",
"wy => way",
"tr => trail"
]
}
},
"analyzer": {
"shingle": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"shingle"
]
}
}
}
【问题讨论】:
-
即使你只得到了你想要的,“4 Walmley Close”仍然会匹配所有三个,因为它被标记为“4 walmley”和“walmley close”,后者仍然出现在所有三个。
标签: elasticsearch lucene