Elasticsearch, tire and autocomplete Elasticsearch, tire and autocomplete elasticsearch elasticsearch

Elasticsearch, tire and autocomplete


Here's what I did using analyzers for doing a search on names of businesses when I used ElasticSearch. Place this inside your mapping block and modify the index appropriately -- I think this will give you what you want:

indexes :name, :type => 'multi_field', :fields => {  :name => { :type => 'string', :analyzer => 'standard' },  :"name.exact" => { :type => 'string', :index => :not_analyzed }}

Then inside your search and query blocks, something like:

search do  query do    # either a must match for exact match    boolean(:minimum_number_should_match => 1) do        must { string "name:#{<variable>}" }    end    # or a broader match    string "name:#{<variable>}*"  endend