Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Commit

Permalink
[#289] Added an example of fuzzy query in the Text query integration …
Browse files Browse the repository at this point in the history
…test

This is what you probably want to use when exposing the search interface to your users.

See <http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html>
  • Loading branch information
karmi committed Mar 26, 2012
1 parent 6cde66e commit 137c981
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/integration/text_query_test.rb
Expand Up @@ -9,17 +9,29 @@ class QueryStringIntegrationTest < Test::Unit::TestCase
setup do
Tire.index('articles-test') do
store :type => 'article', :title => '+1 !!!'
store :type => 'article', :title => 'Furry Kitten'
refresh
end
end

should "find article by title" do
results = Tire.search('articles-test') { query { text :title, '+1' } }.results
results = Tire.search('articles-test') do
query { text :title, '+1' }
end.results

assert_equal 1, results.count
assert_equal "+1 !!!", results.first[:title]
end

should "allow to pass options (fuzziness)" do
results = Tire.search('articles-test') do
query { text :title, 'fuzzy mitten', :fuzziness => 0.5, :operator => 'and' }
end.results

assert_equal 1, results.count
assert_equal "Furry Kitten", results.first[:title]
end

end

end
Expand Down

0 comments on commit 137c981

Please sign in to comment.