sil*_*osu 5 wildcard elasticsearch
我正在尝试为建议下拉列表实现通配符.自从我试图找出这个以来,我已经有几天了.:(
我有一份餐馆名单(4000-7000).我想在餐馆名称中使用通配符进行搜索,并首先显示搜索位于文本前面的结果.
我尝试在没有分析器的情况下索引名称字段,使用ngram分析器和我在网上找到的许多其他解决方案,但没有运气.
现在最好的结果我得到了这个设置:
settings:
  analysis: {
    analyzer: {
      default: {
        tokenizer: :keyword, 
        filter: [:lowercase]
      }
    }
  }
和索引名称字段如下:
indexes :name, type: :string, analyzer: :default
搜索:查询:{wildcard:{name:'*le*'}} 
结果:奥尔良的牛肉先生,米勒的酒吧,枫叶的梅洛,Le Bouchon,Les Nomades,Leonardo's Ristorante,Lem's Bar-BQ House,Le Petit Paris ,Joy Yee的面条 - 唐人街,J.Alexander(林肯公园),印度花园 -  Streeterville,Goose Island Brewpub  -  Wrigleyville,Tweet ...让我们吃!,Arco de Cuchilleros,Al's#1意大利牛肉 - 小意大利
我希望以' le ' 开头的结果在前面,以获得更高的分数.因为通常人们会搜索一个以餐馆开头的餐馆.但是我不能在没有*的情况下进行搜索,因为我也想要包含此结果的结果,但结果中得分较低.比如上面的'Le Colonial','Le Petit Paris','Les Nomades'应该在前面.
我怎么能做到这一点?
另一个问题是我的表现.我知道展位中的通配符结束了,这是最糟糕的情况,但我找不到任何解决方案,给我一些结果与ngram或shingle一样好.
Bla*_*POP 12
使用提升选择顶部的第一场比赛.
使用两个通配符查询
curl -XPOST "http://hostname:9200/index/type/_search" -d'
{
"size": 2000,
"query": {
    "bool": {
        "should": [
            {
                "wildcard": {
                    "name": {
                        "value": "*le*"
                    }
                }
            },
            {
                "wildcard": {
                    "name": {
                        "value": "le*",
                        "boost": 5
                    }
                }
            }
        ]
    }
}
}'
使用一个通配符和一个prefixquery
curl -XPOST "http://hostname:9200/index/type/_search" -d'
{
"size": 2000,
"query": {
    "bool": {
        "should": [
            {
                "wildcard": {
                    "name": {
                        "value": "*le*"
                    }
                }
            },
            {
                "prefix": {
                    "name": {
                        "value": "le",
                        "boost": 2
                    }
                }
            }
        ]
    }
}
}'
| 归档时间: | 
 | 
| 查看次数: | 2022 次 | 
| 最近记录: |