我有一个看起来像这样的文件
Name
Thomy tyson Olando Magua
使用ngram我能够实现通配符搜索,这样如果我输入omy tyson它可以返回上面的文档,与此sql查询非常相似
select name from table where name like '%omy tyson%'
PUT sample
{
"settings": {
"analysis": {
"analyzer": {
"my_ngram_analyzer": {
"tokenizer": "my_ngram_tokenizer"
}
},
"tokenizer": {
"my_ngram_tokenizer": {
"type": "nGram",
"min_gram": "2",
"max_gram": "15"
}
}
}
},
"mappings": {
"typename": {
"properties": {
"name": {
"type": "string",
"fields": {
"search": {
"type": "string",
"analyzer": "my_ngram_analyzer"
}
}
}
}
}
}
}
PUT sample/typename/2
{
"name": "Thomy tyson Olando Magua"
}
{
"query": {
"bool": {
"should": [
{
"term": {
"name.search": "omy tyson"
}
}
]
}
}
}
在弹性搜索中是否有一种方法可以在2个不同的单词上执行通配符搜索,这些单词由其他单词分隔,如
select name from table where name like '%omy Magua%'
所以在这种情况下我想对第一个和第四个单词进行部分搜索。 任何反馈都会有所帮助