该完成提示器要使用什么Elasticsearch Analyzer? [英] What Elasticsearch Analyzer to use for this completion suggester?

查看:101
本文介绍了该完成提示器要使用什么Elasticsearch Analyzer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Elasticsearch还是很陌生,目前正试图针对completion suggester

绕过分析仪

我有一个这样的地方列表:

  • 伦敦
  • 伦敦眼
  • 伦敦地牢
  • 等...

通过将完成提示的映射设置为以下内容:

'place_suggest': {
     'type': 'completion',
     'payloads': true,
     'index_analyzer' : 'stop',
     'search_analyzer' : 'stop',
     'preserve_position_increments' : false
}

现在,当建议者文本输入只是字母L

时,我就能获得上述所有三个建议.

但是我希望当用户键入单词eye时返回The London Eye,并且同样希望当用户键入Dungeon时返回The London Dungeon(当然,这些术语的任何前缀)

在今天的大部分时间里,我一直在使用不同的分析仪和设置,但没有成功.

要实现上述目标,我需要使用哪种分析仪?

解决方案

您可以使用完成建议程序.使用多个输入字段和一个统一的输出.如果输入字段之一匹配,则将返回输出字段.

curl -X PUT localhost:9200/places/place/1 -d '
{
    "title" :         "The London Eye",
    "place_suggest" : {
        "input" :      [
            "The London Eye",
            "Eye"
        ],
        "output":"The London Eye"
     }
}'

curl -X PUT localhost:9200/places/place/2 -d '
{  
    "title" :         "The London Dungeon",
    "place_suggest" : {
        "input" :      [
            "The London Dungeon",
            "Dungeon"
         ],
         "output":"The London Dungeon"
    }
}'

I'm very new to Elasticsearch and am currently trying to get my head around analyzers with respect to the completion suggester

I have a list of places like so:

  • London
  • The London Eye
  • The London Dungeon
  • etc...

By setting the mapping for a completion suggester to the following:

'place_suggest': {
     'type': 'completion',
     'payloads': true,
     'index_analyzer' : 'stop',
     'search_analyzer' : 'stop',
     'preserve_position_increments' : false
}

I am now able to get all three of the above suggestions returned when the suggesters text input is simply the letter L

However I would like The London Eye to be returned when the user types the word eye and likewise to have The London Dungeon returned when the user types Dungeon (And of course for any prefixes of those terms)

I have been playing with the different analyzers and settings for the better part of today with no success.

What kind of analyzer do I need to use to achieve the above?

解决方案

You can achieve what you want with the Completion Suggester. Use multiple input fields and a single unified output. If there is a match on one of the input fields the output field will be returned.

curl -X PUT localhost:9200/places/place/1 -d '
{
    "title" :         "The London Eye",
    "place_suggest" : {
        "input" :      [
            "The London Eye",
            "Eye"
        ],
        "output":"The London Eye"
     }
}'

curl -X PUT localhost:9200/places/place/2 -d '
{  
    "title" :         "The London Dungeon",
    "place_suggest" : {
        "input" :      [
            "The London Dungeon",
            "Dungeon"
         ],
         "output":"The London Dungeon"
    }
}'

这篇关于该完成提示器要使用什么Elasticsearch Analyzer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆