0
votes

I'm currently using Tire to access my ES data however I've not been able to get it to do an exact match, for instance

User.search :per_page => 10 do 
 query do
    boolean do
       must { match :first_name, 'tom'}
       must { match :last_name, 'smith'}
       end
   end
end

However that returns firstnames that are tom, tomas, tommy and tomiena.. when I'd like it to only match tom.

2
It depends on used analyzer. Whats your mapping?vhyza

2 Answers

1
votes

Try the match_phrase query,

User.search :per_page => 10 do 
 query do
    boolean do
       must { match :first_name, 'tom', :type => :phrase}
       must { match :last_name, 'smith', :type => :phrase}
       end
   end
end
0
votes

You can try with a query_string query :

User.search :per_page => 10 do 
 query do
    boolean do
       must { string 'first_name:tom'}
       must { string 'last_name:smith'}
       end
   end
end

If that doesn't work it means that you'd have to check on your analyser.