I use QueryBuilders.templateQuery(template, map) to achieve some documents, howerer,the relevance scoring of each document is 1.I hope someone can help me.
template example: 
{ 
"query": { 
"bool": { 
"must": [ 
{ 
"query_string": { 
"default_field": "progress_note", 
"query": "chest pains" 
} 
} 
], 
"must_not": [], 
"should": [] 
} 
}, 
"from": 0, 
"size": 10, 
"sort": [], 
"aggs": {} 
}
             
            
               
               
               
            
            
           
          
            
            
              Hi @jiangshigen ,
It's not clear to me the reason you are using a template query as your query is not a template at all.
Doing a normal query you get the expected score:
POST my_index/doc/1
{
  "progress_note": "chest pains"
}
GET my_index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "default_field": "progress_note",
            "query": "chest pains"
          }
        }
      ],
      "must_not": [],
      "should": []
    }
  },
  "from": 0,
  "size": 10,
  "sort": [],
  "aggs": {}
}
{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.5753642,
    "hits": [
      {
        "_index": "my_index",
        "_type": "doc",
        "_id": "1",
        "_score": 0.5753642,
        "_source": {
          "progress_note": "chest pains"
        }
      }
    ]
  }
} 
 
Can you elaborate your question?
Cheers, 
LG
             
            
               
               
               
            
            
           
          
            
            
              Thank you for your answer. 
I use this way to achieve some documents, howerer,the relevance scoring of each document is 1.
template example:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "progress_note",
"query": "{{queryString}}"
}
}
],
"must_not": 
,
"should": 
}
},
"from": 0,
"size": 10,
"sort": 
,
"aggs": {}
}
            
 
            
               
               
               
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    February 15, 2018,  6:51am
                   
                   
              4 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.