title: Elastic Search sorting and ranking
body: <p>I am using elastic search <strong>version 2.x</strong>. And I have two records which are indexed as:</p>
  
  <ol>
  <li>bathroom wall tile (as "nickname" indexed document column)</li>
  <li>tile wall bathroom (as "nickname" indexed document column)</li>
  </ol>
  
  <p>When I am trying to search for phrase "<strong>tile wall bathroom</strong>" ideally second should appear first because that is exact match and after that first will appear because all the 3 words matches(tile, wall and bathroom).</p>
  
  <p>I put sorting in my query based on columns. Below is my elastic search query:</p>
  
  <pre><code>{
                            "query" : {
                                  "filtered" : {
                                        "query" : {
                                              "query_string": {
                                                  "query": "*tile wall bathroom*",
                                                  "fields": [
                                                      "nickname",
                                                      "comments",
                                                      "category_name",
                                                      "subcategory_name",
                                                      "document_name",
                                                      "web_links",
                                                      "document_extension",
                                                      "property_name",
                                                      "document_content"
                                                  ],                                                    
                                                  "analyze_wildcard": true
                                              }
                                        },
                                        "filter" : { 
                                              "and" : [
                                                    {"term" : {"property_id" : "6"}}
                                              ]
                                        }
                                  }
                            },
                            "size": 10,
                            "sort": ["nickname", "comments", "web_links", "document_name"]
                      }
  </code></pre>
  
  <p>For reference please find attached image.<a href="https://i.stack.imgur.com/LW0Lp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LW0Lp.png" alt="enter image description here"></a></p>
  
  <p>Thanks in advance!!!</p>