2015-11-16 38 views
1

我有一个字段说“testField”,其中可以有许多字符串值类似。只要字段中的值是特定字符串,例如“testValue”,我就需要提高分数。我如何在elasticsearch中做到这一点?elasticsearch基于字符串得分

回答

2

您可以尝试使用function_score

{ 
    "query": { 
    "function_score": { 
     "query": { 
     "match_all": {} 
     }, 
     "functions": [ 
     { 
      "filter": { 
      "term": { 
       "testField": "testValue" 
      } 
      }, 
      "boost_factor": 15 
     } 
     ] 
    } 
    } 
}