zoukankan      html  css  js  c++  java
  • es建议查询

      在输入的时候,都会给用户一个建议。

    1.es中有三种建议器

      Term suggester

      Phrase suggester

      Completion suggester

    2.字段

      

    3.Term suggester

      term 词条建议器,对给输⼊的⽂本进⾏分词,为每个分词提供词项建议

    POST /nba_lastest/_search
    {
      "suggest": {
        "my-suggester": {
          "text": "Stev",
          "term": {
            "suggest_mode": "missing",
            "field": "displayNameEn"
          }
        }
      }
    }
    

      效果:

    {
      "took" : 5,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 0,
          "relation" : "eq"
        },
        "max_score" : null,
        "hits" : [ ]
      },
      "suggest" : {
        "my-suggester" : [
          {
            "text" : "stev",
            "offset" : 0,
            "length" : 4,
            "options" : [
              {
                "text" : "seth",
                "score" : 0.5,
                "freq" : 2
              },
              {
                "text" : "stein",
                "score" : 0.5,
                "freq" : 2
              },
              {
                "text" : "steven",
                "score" : 0.5,
                "freq" : 2
              }
            ]
          }
        ]
      }
    }
    

      

    4.Phrase suggester

      phrase 短语建议,在term的基础上,会考量多个term之间的关系,⽐如是否同时出现在索 引的原⽂⾥,相邻程度,以及词频等

    POST /nba_lastest/_search
    {
      "suggest": {
        "my-suggester": {
          "text": "jamse harden",
          "phrase": {
            "field": "displayNameEn"
          }
        }
      }
    }
    

      效果:

    {
      "took" : 4,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 0,
          "relation" : "eq"
        },
        "max_score" : null,
        "hits" : [ ]
      },
      "suggest" : {
        "my-suggester" : [
          {
            "text" : "jamse harden",
            "offset" : 0,
            "length" : 12,
            "options" : [
              {
                "text" : "james harden",
                "score" : 0.0036367897
              },
              {
                "text" : "jamal harden",
                "score" : 0.0022790073
              },
              {
                "text" : "jake harden",
                "score" : 0.001686592
              },
              {
                "text" : "jose harden",
                "score" : 0.001686592
              }
            ]
          }
        ]
      }
    }
    

      

    5.Completion suggester Completion 完成建议

      这里需要的是将字段的type修改为competition

  • 相关阅读:
    编写你的应用程序(二)、原生客户端模块
    编写你的应用程序(一)、应用结构
    checkpoint机制,show engine innodb status
    InnoDB关键特性,innodb_old_blocks_time,锁,内存管理,latch争用
    Innodb引擎,MySQL修改参数
    MySQL数据库体系结构
    IT行业数据库分析
    生成一个千万行的表
    范式小知识
    MySQL触发器
  • 原文地址:https://www.cnblogs.com/juncaoit/p/12820011.html
Copyright © 2011-2022 走看看