title: ElasticSearch error: [function_score] malformed query, expected [END_OBJECT] but found [FIELD_NAME]
body: <p>The following JSON structure gives me an error when doing a query: </p>
  
  <pre><code>{                                                                                                                                                                                                                                                                                        
      "query": {                                                                                                                                                                                                                                                                           
          "function_score": {                                                                                                                                                                                                                                                              
              "query": {                                                                                                                                                                                                                                                                   
                  "bool": {                                                                                                                                                                                                                                                                
                      "should": [                                                                                                                                                                                                                                                          
                          {                                                                                                                                                                                                                                                                
                              "multi_match": {                                                                                                                                                                                                                                             
                                  "query": "BRCA1",                                                                                                                                                                                                                                        
                                  "fuzziness": "AUTO",                                                                                                                                                                                                                                     
                                  "fields": [                                                                                                                                                                                                                                              
                                      "Long_Name",                                                                                                                                                                                                                                         
                                      "Short_Name",                                                                                                                                                                                                                                        
                                      "Uniprot_ID^10",                                                                                                                                                                                                                                     
                                      "Genes^2",                                                                                                                                                                                                                                           
                                      "Diseases^2",                                                                                                                                                                                                                                        
                                      "Function",                                                                                                                                                                                                                                          
                                      "Domains"                                                                                                                                                                                                                                            
                                  ]                                                                                                                                                                                                                                                        
                              }                                                                                                                                                                                                                                                            
                          },                                                                                                                                                                                                                                                               
                          {                                                                                                                                                                                                                                                                
                              "term": {                                                                                                                                                                                                                                                    
                                  "Is_Reviewed": true                                                                                                                                                                                                                                      
                              }                                                                                                                                                                                                                                                            
                          },                                                                                                                                                                                                                                                               
                          {                                                                                                                                                                                                                                                                
                              "term": {                                                                                                                                                                                                                                                    
                                  "Has_Function": true                                                                                                                                                                                                                                     
                              }                                                                                                                                                                                                                                                            
                          }                                                                                                                                                                                                                                                                
                      ]                                                                                                                                                                                                                                                                    
                  }                                                                                                                                                                                                                                                                        
              }                                                                                                                                                                                                                                                                            
          },                                                                                                                                                                                                                                                                               
          "field_value_factor": {                                                                                                                                                                                                                                                          
              "field": "Number_Of_Structures"                                                                                                                                                                                                                                              
          }                                                                                                                                                                                                                                                                                
      },                                                                                                                                                                                                                                                                                   
      "size": 100                                                                                                                                                                                                                                                                          
  }  
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>[function_score] malformed query, expected [END_OBJECT] but found [FIELD_NAME]
  </code></pre>
  
  <p>The bool query on its own works perfectly, but as soon as I use function_score, it stops working. I have tried to follow this example: <a href="https://www.elastic.co/guide/en/elasticsearch/guide/master/boosting-by-popularity.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/guide/master/boosting-by-popularity.html</a></p>
  
  <p>Any ideas as to what I am doing wrong would be much appreciated!</p>