小编Par*_*ngh的帖子

Elasticsearch上下文建议,bool on contexts

我正在使用上下文建议器,我想知道我们是否可以设置上下文的范围用于建议而不是使用所有上下文.

目前,查询需要匹配所有上下文.我们可以在上下文中添加"OR"操作和/或指定用于特定查询的上下文吗?

这里为例:映射:

PUT /venues/poi/_mapping
{
  "poi" : {
    "properties" : {
      "suggest_field": {
        "type": "completion",
        "context": {
          "type": { 
            "type": "category"
          },        
          "location": { 
            "type": "geo",
            "precision" : "500m"
          }
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

然后我索引一个文件:

 {
  "suggest_field": {
    "input": ["The Shed", "shed"],
    "output" : "The Shed - fresh sea food",
    "context": {
      "location": {
        "lat": 51.9481442,
        "lon": -5.1817516
      },      
      "type" : "restaurant"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

查询:

{
  "suggest" : {
    "text" : "s",
    "completion" : { …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

8
推荐指数
1
解决办法
1321
查看次数

标签 统计

elasticsearch ×1