title: elasticsearch case insensitive term filter search on not_analyzed field
body: <p>There are similar questions asked here <a href="https://stackoverflow.com/questions/24036708/elasticsearch-map-case-insensitive-to-not-analyzed-documents">Elasticsearch Map case insensitive to not_analyzed documents</a>, however mine is a slightly different because I deal with special characters.</p>
  <p>Most people recommend using a <code>keyword analyzer</code> combined with <code>lowercase filter</code>. However, this does not work for my case because keyword analyzer tokenizes on spaces, and special characters like <code>^, #, etc</code>. which break the type of support I'm going for.</p>
  <p>i.e.</p>
  <ol>
  <li><code>^HELLOWORLD</code> should be matched by searching <code>^helloworld</code>, but not <code>helloworld</code></li>
  <li><code>#FooBar</code> should be matched by <code>#foobar</code> but not <code>foobar</code>.</li>
  <li><code>Foo Bar</code> should be matched by <code>foo bar</code>, but not <code>foo</code> or <code>bar</code>.</li>
  </ol>
  <p>Similar functionality with what we see here <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html#_term_filter_with_numbers" rel="noreferrer">https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html#_term_filter_with_numbers</a>, but with case insensitivity.</p>
  <p>Does anyone know how to accomplish this?</p>
  <h2>EDIT 1:</h2>
  <p>It seems the core of my problem was with multi-field, as keyword+lowercase seems to resolve the question posed in the title. However, it would be more accurate to pose this question for a multi-field value property.</p>
  <p>test_mapping.json:</p>
  <pre><code>{
    &quot;properties&quot; : {
      &quot;productID1&quot; : {
        &quot;type&quot; : &quot;string&quot;,
        &quot;index_analyzer&quot; :  &quot;keyword_lowercase&quot;,
        &quot;search_analyzer&quot; : &quot;keyword_lowercase&quot;
      },
      &quot;productID2&quot; : {
        &quot;type&quot;: &quot;multi_field&quot;,
        &quot;keyword_edge_ID&quot;: {
          &quot;type&quot;: &quot;string&quot;, 
          &quot;index_analyzer&quot;:&quot;keyword_lowercase_edge&quot;, 
          &quot;search_analyzer&quot;:&quot;keyword_lowercase_edge&quot;
        },
        &quot;productID2&quot;: {
          &quot;type&quot;: &quot;string&quot;, 
          &quot;index&quot;: &quot;analyzed&quot;, 
          &quot;store&quot;: &quot;yes&quot;, 
          &quot;index_analyzer&quot;:&quot;keyword_lowercase&quot;, 
          &quot;search_analyzer&quot;:&quot;keyword_lowercase&quot;
        }
      }
    }
  }
  </code></pre>
  <p>test.json:</p>
  <pre><code>{
    &quot;index&quot;: {
      &quot;analysis&quot;: {
        &quot;filter&quot;:{
          &quot;edgengramfilter&quot;: {
            &quot;type&quot;: &quot;edgeNgram&quot;,
            &quot;side&quot;: &quot;front&quot;,
            &quot;min_gram&quot;: 1,
            &quot;max_gram&quot;: 32
          }
        },
        &quot;analyzer&quot;: {
          &quot;keyword_lowercase&quot; : {
            &quot;type&quot; : &quot;custom&quot;,
            &quot;tokenizer&quot;: &quot;keyword&quot;,
            &quot;filter&quot;: &quot;lowercase&quot;
          },
          &quot;keyword_lowercase_edge&quot;: {
              &quot;tokenizer&quot;: &quot;keyword&quot;,
              &quot;filter&quot;: [&quot;lowercase&quot;, &quot;edgengramfilter&quot;]
          }
        }
      }
    }
  }
  </code></pre>
  <p>Shell script to create index with mappings:</p>
  <pre><code>#!/bin/sh
  
  ES_URL=&quot;http://localhost:9200&quot;
  
  curl -XDELETE $ES_URL/test
  curl -XPOST $ES_URL/test/ --data-binary @test.json
  curl -XPOST $ES_URL/test/query/_mapping --data-binary @test_mapping.json
  </code></pre>
  <p>POST <code>localhost:9200/test/query</code>:</p>
  <pre><code>{ 
    &quot;productID1&quot; : &quot;^A&quot;,
    &quot;productID2&quot; : &quot;^A&quot; 
  }
  </code></pre>
  <p>I'd like it so that I can match against productID2 with &quot;^A&quot;, but it is returning no results right now, but it works when I do the same query against productID1. <code>{&quot;query&quot;: { &quot;match&quot;: { &quot;productID2&quot;: &quot;^A&quot; }}}</code></p>