elastic_searchable 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/elastic_searchable.gemspec +2 -2
- data/lib/elastic_searchable/queries.rb +5 -3
- data/test/test_elastic_searchable.rb +11 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/elastic_searchable.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{elastic_searchable}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ryan Sonnek"]
|
12
|
-
s.date = %q{2011-01
|
12
|
+
s.date = %q{2011-02-01}
|
13
13
|
s.description = %q{integrate the elastic search engine with rails}
|
14
14
|
s.email = %q{ryan@codecrate.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -14,10 +14,12 @@ module ElasticSearchable
|
|
14
14
|
query = {:query => query}
|
15
15
|
end
|
16
16
|
hits = ElasticSearchable.searcher.search query, index_options.merge(options)
|
17
|
+
ids = hits.collect(&:_id)
|
18
|
+
results = self.find(ids).sort_by {|result| ids.index(result.id.to_s) }
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
page = WillPaginate::Collection.new(hits.current_page, hits.per_page, hits.total_entries)
|
21
|
+
page.replace results
|
22
|
+
page
|
21
23
|
end
|
22
24
|
|
23
25
|
# counts the number of results for this query.
|
@@ -105,6 +105,17 @@ class TestElasticSearchable < Test::Unit::TestCase
|
|
105
105
|
assert_equal 1, @results.total_entries
|
106
106
|
end
|
107
107
|
end
|
108
|
+
|
109
|
+
context 'sorting search results' do
|
110
|
+
setup do
|
111
|
+
@second_post = Post.create :title => 'foo', :body => "second bar"
|
112
|
+
Post.create_index
|
113
|
+
@results = Post.search 'foo', :sort => 'id:reverse'
|
114
|
+
end
|
115
|
+
should 'sort results correctly' do
|
116
|
+
assert_equal @second_post, @results.first
|
117
|
+
end
|
118
|
+
end
|
108
119
|
end
|
109
120
|
|
110
121
|
class Blog < ActiveRecord::Base
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_searchable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01
|
18
|
+
date: 2011-02-01 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|