-
Notifications
You must be signed in to change notification settings - Fork 533
fuzzy query dsl support + term api improvement #289
Conversation
ps: this pull request is still missing tests. I looked at the code but didn't find where the query's tests should live. There's text_query_test.rb, range_queries_test.rb, query_string_test.rb. Could someone point me if there's some kind of pattern for queries integration tests? |
Hi, thanks for the patches! 1/ Regarding the 2/ The fuzzy query can, in fact, be quite easily be done with the "raw API", by passing a Hash, just as the Readme instructs. We could or maybe should support stuff like pagination better with the "raw API". 3/ Yes, every query type needs corresponding tests: unit tests to check the raw behaviour (proper encoding etc), and an integration test. The convention is to put unit tests in the 4/ The missing support for options looks like a bug. Could you add a unit/integration test demonstrating the bug and filing a separate issue? |
term :name, query but, when you want to pass options, you have to changed it to: term :name, { term: query, boost: 2 } which I think it's confusing(even more for newcomers). After the change I've made, all you have to do is pass the options term :name, query, boost: 2 |
+1 for the core |
well, I think that's it. unit + integration tests created. |
+1 for core |
👍 for core |
+1 for core |
3 similar comments
+1 for core |
+1 for core |
+1 for core |
See <http://www.elasticsearch.org/guide/reference/query-dsl/fuzzy-query.html> This is a combination of 4 commits: * initial implementation of fuzzy api * just a bit improvement to the docs to make fuzzy example easier to read * unit tests for fuzzy query * integration test for fuzzy query
This is a combination of 3 commits: * little improvement of term api * fixing term tests after api changing * unit tests for term query with an option hash
…tured the search query test suite
…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>
… example of "unsupported" query
@BlackdolphinMedia, @gregoriokusowski, @fmeyer, @rafaelsteil, @cmilfont, @peleteiro, @andreazevedo, I appreciate your interest in Tire! However this is not Rails, please add something meaningful to the discussion... |
@plentz Cleaned up and merged the code, thanks! For the time being it stays in core, the structure of code fo queries must be improved. Notice, that for "fuzzy" queries, there's a standard Lucene operator for the "query_string" type. In majority of cases, it actually makes sense to use the "text" query with the You can see the example in the integration test, commit 137c981. |
@plentz, this is just a summary of what I did when splitting your commit plentz/tire@eb9992b, which combined different features/changes into one. # Get the changes and update from master via rebase
git checkout -b issues/289
git pull https://github.com/plentz/tire.git master
git rebase master
# Start interactive rebase of all commits not on master
git rebase -i master
# For eb9992b commit, mark it as "edit"
# Now, reset the commit, but leave the changes on disk -- preparing the commit "split"
git reset HEAD^
# Add only the portions we want
git add -p
# Commit only the selected changes as a split commit
git commit -v -c eb9992b
# Repeat with the rest of the code, splitting the commit...
# Continue the rebase...
git rebase --continue
# (We also squashed the commits)
# Now let's check what we have prepared
git log HEAD --oneline --not master
# We can safely merge that into master See these sources: |
* upstream/master: (39 commits) Release 0.4.0 [GEMS] Relaxed gem dependencies for "rest-client", "multi_json" and "bundler" Release 0.4.0.rc [karmi#218] Cleaned up the test suite for document_type in Index#bulk_store [karmi#218] Fixed the incorrect serialization of `document_type` in Index#bulk_store [FIX] Fixed displaying of Rake task usage [karmi#289] Update README and documentation, use the `prefix` query as the example of "unsupported" query [karmi#289] Added an example of fuzzy query in the Text query integration test [TEST] Improved code in the Text Query integration test [TEST] Improved code legibility in the Explanation integration test [TEST] Improved code legibility in the DSL integration test [karmi#289] Cleaned up the code for "term" and "fuzzy" queries and restructured the search query test suite [karmi#289] Improvements to the "term" query type [karmi#289] Added the "fuzzy" query type [GEMS] Updated and cleaned up gem dependencies Restructured the test suite for Ruby 1.8 unit test compatibility Added Ruby 1.8 compatibility for `Utils.escape/unescape` [TEST] Removed the "supermodel" gem and used the "redis-persistence" gem [ACTIVEMODEL] Fixed and cleaned up URL-escaping of document type [UTILS] Added the `Tire::Utils` module ...
For newcomers(like me - but not just me), It's pretty hard to find out how to add support to fuzzy searchs. It would be nicer to have some api to easier archive querys with fuzzy(and maybe flt).
disclaimer: I know that
Tire.search 'customers', :query => { :fuzzy => { :name => 'John' } }
work, but it's pretty hard to include things like pagination, etc.this is an initial implementation and could be improved. I also added a little improvement to the
term
api, which allow a option's hash parameter to be passed.