title: ElasticSearch - Searching with hyphens
body: <p>Elastic Search 1.6</p>
  
  <p>I want to index text that contains hyphens, for example U-12, U-17, WU-12, t-shirt... and to be able to use a "Simple Query String" query to search on them.</p>
  
  <p>Data sample (simplified):</p>
  
  <pre><code>{"title":"U-12 Soccer",
   "comment": "the t-shirts are dirty"}
  </code></pre>
  
  <p>As there are quite a lot of questions already about hyphens, I tried the following solution already:</p>
  
  <p>Use a Char filter: <a href="https://stackoverflow.com/questions/23637493/elasticsearch-searching-with-hyphens-in-name">ElasticSearch - Searching with hyphens in name</a>.</p>
  
  <p>So I went for this mapping:</p>
  
  <pre><code>{
    "settings":{
      "analysis":{
        "char_filter":{
          "myHyphenRemoval":{
            "type":"mapping",
            "mappings":[
              "-=&gt;"
            ]
          }
        },
        "analyzer":{
          "default":{
            "type":"custom",
            "char_filter":  [ "myHyphenRemoval" ],
            "tokenizer":"standard",
            "filter":[
              "standard",
              "lowercase"
            ]
          }
        }
      }
    },
    "mappings":{
      "test":{
        "properties":{
          "title":{
            "type":"string"
          },
          "comment":{
            "type":"string"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Searching is done with the following query:</p>
  
  <pre><code>{"_source":true,
    "query":{
      "simple_query_string":{
        "query":"&lt;Text&gt;",
        "default_operator":"AND"
      }
    }
  }
  </code></pre>
  
  <ol>
  <li><p>What works:</p>
  
  <p>"U-12", "U*", "t*", "ts*"</p></li>
  <li><p>What didn't work:</p>
  
  <p>"U-*", "u-1*", "t-*", "t-sh*", ...</p></li>
  </ol>
  
  <p>So it seems the char filter is not executed on search strings?
  What could I do to make this work?</p>