elastic_searchable 0.1.0 → 0.1.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 CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{elastic_searchable}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.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"]
@@ -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
- hits = search_hits(query, options)
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: 27
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Sonnek