Permalink
Browse files

+ 3.6.13

  • Loading branch information...
1 parent 055c42a commit e2c1a36d38ef7d8547f897023779339b1acdb57f @floere committed Dec 1, 2011
View
@@ -1,5 +1,9 @@
h2. Upcoming Version
+h2. Version 3.6.13
+
+* hanke: (server) Fix for exact first matching (thanks geelen!).
+
h2. Version 3.6.12
* hanke: (server) @Picky::Search@ option @terminate_early(integer)@ or @terminate_early(with_extra_allocations: integer)@ introduces early termination. If in your interface you only need the ids and no total, then this is the option for you. Calling @terminate_early@ without parameters will use 0 as the default.
@@ -11,6 +11,8 @@ module Category
#
class ExactFirst
+ # TODO Refactor!
+ #
delegate :add,
:qualifiers,
:exact,
@@ -26,6 +28,10 @@ class ExactFirst
:load,
:empty,
+ :prepared_index_file,
+ :tokenizer,
+ :cache,
+ :from,
:bundle_for,
:build_realtime_mapping,
@@ -197,6 +197,7 @@ def prepare
queries.prepare
run = Search.new data
+ run.terminate_early
# Quick sanity check.
#
@@ -4,6 +4,10 @@
describe "exact first" do
+ before(:each) do
+ Picky::Indexes.clear_indexes
+ end
+
it 'returns exact results first' do
index = Picky::Index.new :exact_first do
source { [] }
@@ -26,4 +30,28 @@
exact_first.search("disc").ids.should == [2, 1] # Not exact, so not first.
end
+ it 'can do dumps/loads etc.' do
+ require 'ostruct'
+
+ data = Picky::Index.new :exact_first do
+ source { [
+ OpenStruct.new(id: 1, text: "discofox"),
+ OpenStruct.new(id: 2, text: "disco")
+ ] }
+ category :text, partial: Picky::Partial::Substring.new(from: 1)
+ end
+ normal = Picky::Search.new data
+ Picky::Indexes.index_for_tests
+
+ normal.search("disco").ids.should == [1, 2] # Ordering with which it was added.
+
+ data = Picky::Wrappers::Category::ExactFirst.wrap data
+ exact_first = Picky::Search.new data
+
+ Picky::Indexes.index_for_tests
+
+ exact_first.search("disco").ids.should == [2, 1] # Exact first.
+ exact_first.search("disc").ids.should == [1, 2] # Not exact, so not first.
+ end
+
end
View
@@ -1,3 +1,3 @@
module Picky
- VERSION = '3.6.12'
+ VERSION = '3.6.13'
end

0 comments on commit e2c1a36

Please sign in to comment.