2017-07-28 59 views
1

我有一个问题,我想搜索结果使用建议。 我喜欢的类型是这样es查询在elasticsearch中的建议5.0.1

` 
{ 
    "name": { 
     "input": [ 
      "uers1" 
     ] 
    }, 
    "usertype": 1 
}{ 
    "name": { 
     "input": [ 
      "uers2" 
     ] 
    }, 
    "usertype": 2 
}` 

模式我想搜索数据的建议,这样的

`{ 
    "suggest": { 
     "person_suggest": { 
      "text": "us", 
      "completion": { 
       "field": "name" 
      } 
     } 
    } 
}` 

查询而像这些

`{ 
    "_shards": { 
     "total": 1, 
     "successful": 1, 
     "failed": 0 
    }, 
    "person_suggest": [ 
     { 
      "text": "word", 
      "offset": 0, 
      "length": 4, 
      "options": [ 
       { 
        "name": "user1", 
        "usertype": 1, 
        "score": 1 
       }, 
       { 
        "text": "user2", 
        "usertype": 2, 
        "score": 1 
       } 
      ] 
     } 
    ] 
} ` 

的结果,但我只想要结果usertype = 1,就像在mysql中添加where条件一样。任何机构都可以帮助我?我想要一个DSL查询。很多。

回答

0

你不能过滤完成建议查询。针对您的问题的解决方案,为每个usertype制作不同的完成字段或使用nGram分析器使用标准查询。

+0

确定thx非常多 – littletwolee