title: Symbols in query-string for elasticsearch
body: <p>I have "documents" (activerecords) with an attribute called deviations. The attribute has values like "Bin X" "Bin $" "Bin q" "Bin %" etc.</p>
  
  <p>I am trying to use tire/elasticsearch to search the attribute. I am using the whitespace analyzer to index the deviation attribute. Here is my code for creating the indexes:</p>
  
  <pre><code>settings :analysis =&gt; {
      :filter  =&gt; {
        :ngram_filter =&gt; {
          :type =&gt; "nGram",
          :min_gram =&gt; 2,
          :max_gram =&gt; 255
        },
        :deviation_filter =&gt; {
          :type =&gt; "word_delimiter",
          :type_table =&gt; ['$ =&gt; ALPHA']
        }
      },
      :analyzer =&gt; {
        :ngram_analyzer =&gt; {
          :type  =&gt; "custom",
          :tokenizer  =&gt; "standard",
          :filter  =&gt; ["lowercase", "ngram_filter"]
        },
        :deviation_analyzer =&gt; {
          :type =&gt; "custom",
          :tokenizer =&gt; "whitespace",
          :filter =&gt; ["lowercase"]
        }
      }
    } do
      mapping do
        indexes :id, :type =&gt; 'integer'
        [:equipment, :step, :recipe, :details, :description].each do |attribute|
          indexes attribute, :type =&gt; 'string', :analyzer =&gt; 'ngram_analyzer'
        end
        indexes :deviation, :analyzer =&gt; 'whitespace'
      end
    end
  </code></pre>
  
  <p>The search seems to work fine when the query string contains no special characters. For example <code>Bin X</code> will return only those records that have the words <code>Bin</code> AND <code>X</code> in them. However, searching for something like <code>Bin $</code> or <code>Bin %</code> shows all results that have the word <code>Bin</code> almost ignoring the symbol (results with the symbol do show up higher in the search that results without).</p>
  
  <p>Here is the search method I have created</p>
  
  <pre><code>def self.search(params)
      tire.search(load: true) do
        query { string "#{params[:term].downcase}:#{params[:query]}", default_operator: "AND" }
          size 1000
      end
  end
  </code></pre>
  
  <p>and here is how I am building the search form:</p>
  
  <pre><code>&lt;div&gt;
      &lt;%= form_tag issues_path, :class=&gt; "formtastic issue", method: :get do %&gt;
          &lt;fieldset class="inputs"&gt;
          &lt;ol&gt;
              &lt;li class="string input medium search query optional stringish inline"&gt;
                  &lt;% opts = ["Description", "Detail","Deviation","Equipment","Recipe", "Step"] %&gt;
                  &lt;%= select_tag :term, options_for_select(opts, params[:term]) %&gt;
                  &lt;%= text_field_tag :query, params[:query] %&gt;
                  &lt;%= submit_tag "Search", name: nil, class: "btn" %&gt;
              &lt;/li&gt;
          &lt;/ol&gt;
          &lt;/fieldset&gt;
      &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>