ruby on rails: ElasticSearch / Tire dynamic search on multiple indices -


i've done bunch of searching , haven't been able answer question - isn't repeat (apologies if is)...

preface: i'm using rails & tire perform elasticsearch.

i have object, place, attributes "name", "city", "state", , "zip". indexed follows:

indexes :name, :type => 'multi_field', :fields => {    :name => { :type => 'string', :analyzer => 'snowball' },    :"name.exact" => { :type => 'string', :index => :not_analyzed }  }  indexes :city  indexes :state  indexes :zip  

there 3 conditions searching: 1. name only, 2. (city, state or zip), 3. name , (city, state or zip).

my code "query" block is:

  if (city, state).present?      boolean        must { string "name:#{name}*" } if name.present?        must { string "city:#{city_state}*" }        must { string "state:#{city_state}*" }      end    elsif (zip).present?      boolean        must { string "name:#{name}*" } if name.present?        must { string "zip:#{query_parameters["zip"]}*" }      end    else      string "name:#{name}*" }    end  

the aforementioned search conditions #1 , #2 work expected against multiple tests. however, condition 3 not - seems pay attention "name" field. i'm assuming has using "city_state" variable search on both "city" , "state"... i'm doing because user can enter either "chicago" or "illinois" in city, state / zip text box , search should still work, using either geographic center of chicago or geographic center of illinois, respectively.

anything obvious i'm doing wrong?

however, condition 3 not - seems pay attention "name" field

errr, isn't

string "name:#{name}*" 

telling that?

or did mean

string "#{name}" 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -