码迷,mamicode.com
首页 > 其他好文 > 详细

返回suggester的类型(Returning the type of the suggester)

时间:2017-07-26 14:50:42      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:length   bsp   参数   options   ase   ...   ref   tps   key   

Returning the type of the suggester

  有时你需要知道确切的suggester类型,以解析其结果。 typed_keys参数可用于在响应中更改suggester的名称,它将以其类型为前缀。

  考虑以下两个suggester term 和phrase的例子:

POST _search?typed_keys
{
  "suggest": {
    "text" : "some test mssage",
    "my-first-suggester" : {
      "term" : {
        "field" : "message"
      }
    },
    "my-second-suggester" : {
      "phrase" : {
        "field" : "message"
      }
    }
  }
}

  在回应中,suggester命名将分别改为term#my-first-suggester和phrase#my-second-suggester,以反映每个suggestion的类型:

{
  "suggest": {
    "term#my-first-suggester": [ 【1】
      {
        "text": "some",
        "offset": 0,
        "length": 4,
        "options": []
      },
      {
        "text": "test",
        "offset": 5,
        "length": 4,
        "options": []
      },
      {
        "text": "mssage",
        "offset": 10,
        "length": 6,
        "options": [
          {
            "text": "message",
            "score": 0.8333333,
            "freq": 4
          }
        ]
      }
    ],
    "phrase#my-second-suggester": [ 【2】
      {
        "text": "some test mssage",
        "offset": 0,
        "length": 16,
        "options": [
          {
            "text": "some test message",
            "score": 0.030227963
          }
        ]
      }
    ]
  },
  ...
}

  【1】名字my-first-suggester现在包含term前缀。 

  【2】名字my-second-suggester现在包含phrase前缀。

 

 

原文地址:https://www.elastic.co/guide/en/elasticsearch/reference/5.4/returning-suggesters-type.html

返回suggester的类型(Returning the type of the suggester)

标签:length   bsp   参数   options   ase   ...   ref   tps   key   

原文地址:http://www.cnblogs.com/benjiming/p/7239280.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!