title: ElasticSearch's Fuzzy Query
body: <p>I am brand new to <em>ElasticSearch</em>, and am currently exploring its features. One of them I am interested in is the <em>Fuzzy Query</em>, which I am testing and having troubles to use. It is probably a dummy question so I guess someone who already used this feature will quickly find the answer, at least I hope. :)</p>
  
  <p>BTW I have the feeling that it might not be only related to <em>ElasticSearch</em> but maybe directly to <em>Lucene</em>.</p>
  
  <p>Let's start with a new index named "first index" in which I store an object "label" with value "american football". This is the query I use.</p>
  
  <pre><code>bash-3.2$ curl -XPOST 'http://localhost:9200/firstindex/node/?pretty=true' -d '{
    "node" : {
      "label" : "american football"
    }
  }
  '
  </code></pre>
  
  <p>This is the result I get.</p>
  
  <pre><code>{
    "ok" : true,
    "_index" : "firstindex",
    "_type" : "node",
    "_id" : "6TXNrLSESYepXPpFWjpl1A",
    "_version" : 1
  }
  </code></pre>
  
  <p>So far so good, now I want to find this entry using a fuzzy query. This is the one I send:</p>
  
  <pre><code>bash-3.2$ curl -XGET 'http://localhost:9200/firstindex/node/_search?pretty=true' -d '{
    "query" : {
      "fuzzy" : {
        "label" : {
          "value" : "american football",
          "boost" : 1.0,
          "min_similarity" : 0.0,
          "prefix_length" : 0
        }                       
      }    
     }   
  }
  '
  </code></pre>
  
  <p>And this is the result I get</p>
  
  <pre><code>{
    "took" : 15,
    "timed_out" : false,
    "_shards" : {
      "total" : 5,
      "successful" : 5,
      "failed" : 0
    },
    "hits" : {
      "total" : 0,
      "max_score" : null,
      "hits" : [ ]
    }
  }
  </code></pre>
  
  <p>As you can see, no hit. But now, when I shrink a bit my query's value from "american <strong>football</strong>" to "american <strong>footb</strong>" like this:</p>
  
  <pre><code>bash-3.2$ curl -XGET 'http://localhost:9200/firstindex/node/_search?pretty=true' -d ' {
    "query" : {
      "fuzzy" : {
        "label" : {
          "value" : "american footb",
          "boost" : 1.0,
          "min_similarity" : 0.0,
          "prefix_length" : 0
        }
      }
    }
  }
  '
  </code></pre>
  
  <p>Then I get a correct hit on my entry, thus the result is:</p>
  
  <pre><code>{
    "took" : 0,
    "timed_out" : false,
    "_shards" : {
      "total" : 5,
      "successful" : 5,
      "failed" : 0
    },
    "hits" : {
      "total" : 1,
      "max_score" : 0.19178301,
      "hits" : [ {
        "_index" : "firstindex",
        "_type" : "node",
        "_id" : "6TXNrLSESYepXPpFWjpl1A",
        "_score" : 0.19178301, "_source" : {
          "node" : {
            "label" : "american football"
          }
        }
      } ]
    }
  }
  </code></pre>
  
  <hr>
  
  <p>So, I have several questions related to this test:</p>
  
  <ol>
  <li><p>Why I didn't get any result when performing a query with a value completely equals the my only entry "american <strong>football</strong>"</p></li>
  <li><p>Is it related to the fact that I have a multi-words value?</p></li>
  <li><p>Is there a way to get the "similarity" score in my query result so I can understand better how to find the right threshold for my fuzzy queries</p></li>
  <li><p>There is a page dedicated to <em>Fuzzy Query</em> on ElasticSearch web site, but I am not sure it lists all the potential parameters I can use for the fuzzy query. Were could I find such an exhaustive list?</p></li>
  <li><p>Same question for the other queries actually.</p></li>
  <li><p>is there a difference between a <em>Fuzzy Query</em> and a <em>Query String Query</em> using lucene syntax to get fuzzy matching?</p></li>
  </ol>