elastic_searchable 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/elastic_searchable.gemspec +1 -1
- data/lib/elastic_searchable/index.rb +2 -0
- data/lib/elastic_searchable/queries.rb +6 -10
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/elastic_searchable.gemspec
CHANGED
@@ -4,6 +4,8 @@ module ElasticSearchable
|
|
4
4
|
def create_index
|
5
5
|
self.delete_index
|
6
6
|
ElasticSearchable.searcher.create_index(index_name, @index_options)
|
7
|
+
ElasticSearchable.searcher.update_mapping(@mapping, self.elastic_search_options) if @mapping
|
8
|
+
|
7
9
|
self.find_each do |record|
|
8
10
|
record.local_index_in_elastic_search
|
9
11
|
end
|
@@ -2,15 +2,6 @@ require 'will_paginate/collection'
|
|
2
2
|
|
3
3
|
module ElasticSearchable
|
4
4
|
module Queries
|
5
|
-
# search_hits returns a raw ElasticSearch::Api::Hits object for the search results
|
6
|
-
# see #search for the valid options
|
7
|
-
def search_hits(query, options = {})
|
8
|
-
if query.kind_of?(Hash)
|
9
|
-
query = {:query => query}
|
10
|
-
end
|
11
|
-
ElasticSearchable.searcher.search query, elastic_search_options(options)
|
12
|
-
end
|
13
|
-
|
14
5
|
# search returns a will_paginate collection of ActiveRecord objects for the search results
|
15
6
|
#
|
16
7
|
# see ElasticSearch::Api::Index#search for the full list of valid options
|
@@ -18,7 +9,12 @@ module ElasticSearchable
|
|
18
9
|
# note that the collection may include nils if ElasticSearch returns a result hit for a
|
19
10
|
# record that has been deleted on the database
|
20
11
|
def search(query, options = {})
|
21
|
-
|
12
|
+
options[:fields] ||= '_id'
|
13
|
+
if query.kind_of?(Hash)
|
14
|
+
query = {:query => query}
|
15
|
+
end
|
16
|
+
hits = ElasticSearchable.searcher.search query, elastic_search_options(options)
|
17
|
+
|
22
18
|
results = WillPaginate::Collection.new(hits.current_page, hits.per_page, hits.total_entries)
|
23
19
|
results.replace self.find(hits.collect(&:_id))
|
24
20
|
results
|
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: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|