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

  • 相关阅读:
    grpc学习
    01
    样本1
    杀死长时间占用CPU的进程
    SWFTools pdf2swf 参数详解
    C#自动下载并保存文件示例
    Flex初始化时加载外部XML
    通过XPDF抽取PDF中的中文文本
    Flex操作Json数据示例
    C#下载文件和将文件转换为数据流下载的示例
  • 原文地址:https://www.cnblogs.com/juncaoit/p/12820011.html
Copyright © 2011-2022 走看看