【发布时间】:2016-05-11 15:04:35
【问题描述】:
Elasticsearch 的edgen_n_grams 是否可以设置为在 ES 索引爬取数据时构建多词短语?
我想将这些多词短语用作我正在构建的小型搜索应用程序的搜索建议。
我正在使用 Nutch 爬取一些网站,并使用 ES 对爬取的数据进行索引。
我认为由于 ES 可以在 whitespace 上进行拆分 - 这不应该那么难......但是,我没有得到我预期的结果。所以现在我问这是否有可能做到?
我的 ES 索引是这样设置的
PUT /_template/autocomplete_1
{
"template": "auto*",
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "30",
"token_chars": ["letter","digit","whitespace"]
}
},
"analyzer": {
"autocomplete_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
},
"mappings": {
"doc": {
"_all": {
"enabled": false
},
"properties": {
"anchor": {
"type": "string"
},
"boost": {
"type": "string"
},
"content": {
"type": "string",
"index_analyzer": "autocomplete_analyzer",
"search_analyzer": "standard"
},...
"content" 是每个 Nutch 的 html 正文字段。我使用“内容”,因为我认为它会生成最多的短语。
【问题讨论】:
-
要创建多词短语,您需要shingles,但我不确定您需要哪种自动完成功能。您有示例文档和示例搜索文本吗?
-
@AndreiStefan,类似于搜索电影标题,例如“the fast and the furios”或“fast 5”或“fast 5”,搜索查询将是“f”-I我现在正在阅读带状疱疹
-
@AndreiStefan,我想这正是我一直在寻找的!将信息放入答案中,我会接受,非常感谢。
标签: elasticsearch search-suggestion