我试着索引一些短语,像这样:
"Elasticsearch is a great search engine"索引样
Elasticsearch # word
is # word
a # word
great # word
engine # word
Elasticsearch is # bi-gram
is a # bi-gram
a great # bi-gram
great search # bi-gram
search engine # bi-gram
Elasticsearch is a # tri-gram
is a great # tri-gram
a great search # tri-gram
great search engine # tri-gram我知道如何索引单词(用默认索引器)和索引bigram和trigram(用n克索引器),但不是同时进行。
我该怎么做?
问候
发布于 2014-04-28 13:12:29
您可以使用 type。这是我创造的一个例子-
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 0,
"analysis": {
"filter": {
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms.txt"
},
"my_metaphone": {
"type": "phonetic",
"encoder": "metaphone",
"replace": false
}
},
"analyzer": {
"synonym": {
"tokenizer": "whitespace",
"filter": [
"lowercase",
"synonym"
]
},
"metaphone": {
"tokenizer": "standard",
"filter": [
"my_metaphone"
]
},
"porter": {
"tokenizer": "standard",
"filter": [
"lowercase",
"porter_stem"
]
}
}
}
},
"mappings": {
"type": {
"_all": {
"enabled": false
},
"properties": {
"datafield": {
"type": "multi_field",
"store": "yes",
"fields": {
"datafield": {
"type": "string",
"analyzer": "simple"
},
"metaphone": {
"type": "string",
"analyzer": "metaphone"
},
"porter": {
"type": "string",
"analyzer": "porter"
},
"synonym": {
"type": "string",
"analyzer": "synonym"
}
}
}
}
}
}
}然后,您可以指定要针对哪个字段进行搜索,即datafield.synonym或datafield.bigram。然后,您可以构建您的查询,增加对您的结果最重要的字段。
https://stackoverflow.com/questions/23341860
复制相似问题