activesearch 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/activesearch/elastic_search.rb +4 -2
- data/lib/activesearch/mongoid/model.rb +6 -1
- data/lib/activesearch/version.rb +1 -1
- data/spec/base_spec.rb +1 -1
- data/spec/engines_spec.rb +3 -2
- data/spec/models/elastic_search.rb +5 -1
- data/spec/models/mongoid.rb +5 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -30,7 +30,7 @@ The second parameter must be a conditions hash.**
|
|
30
30
|
|
31
31
|
the :store option allows you to store that value in the index but it won't be used for search.
|
32
32
|
You can also add :if or :unless conditions in the same way you would do with ActiveModel callbacks.
|
33
|
-
If you need
|
33
|
+
If you need virtual options, pass a symbol instead:
|
34
34
|
|
35
35
|
search_by :options_for_search
|
36
36
|
|
@@ -17,7 +17,9 @@ module ActiveSearch
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def to_indexable
|
20
|
-
|
20
|
+
elastic_properties.keys.inject({_type: self.elastic_type}) do |memo,field|
|
21
|
+
memo.merge(field => self.send(field))
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
protected
|
@@ -49,7 +51,7 @@ module ActiveSearch
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def elastic_properties
|
52
|
-
props = {}
|
54
|
+
props = {id: {type: 'string'}}
|
53
55
|
|
54
56
|
search_fields.each_with_object(props) do |field,hash|
|
55
57
|
hash[field] = {type: 'string'}
|
@@ -19,7 +19,12 @@ module ActiveSearch
|
|
19
19
|
if options && options[:store]
|
20
20
|
self._stored = {}
|
21
21
|
options[:store].each do |f|
|
22
|
-
|
22
|
+
|
23
|
+
if original.fields[f.to_s] && original.fields[f.to_s].localized?
|
24
|
+
self._stored[f] = original.send("#{f}_translations")
|
25
|
+
else
|
26
|
+
self._stored[f] = original.send(f) if original.send(f).present?
|
27
|
+
end
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
data/lib/activesearch/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
data/spec/engines_spec.rb
CHANGED
@@ -30,10 +30,11 @@ Dir[File.join(File.dirname(__FILE__), 'models', '*.rb')].map { |f| File.basename
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should find the expected documents" do
|
33
|
-
results = ActiveSearch.search("findable").map { |doc| doc.to_hash.select { |k,v| %w[title junk].include?(k.to_s) } }
|
33
|
+
results = ActiveSearch.search("findable").map { |doc| doc.to_hash.select { |k,v| %w[title junk virtual].include?(k.to_s) } }
|
34
34
|
results.sort_by { |result| result["title"] }.should == [
|
35
35
|
{
|
36
|
-
"title"
|
36
|
+
"title" => "Another findable title",
|
37
|
+
"virtual" => "virtual"
|
37
38
|
},
|
38
39
|
{
|
39
40
|
"title" => "Findable Findable",
|
data/spec/models/mongoid.rb
CHANGED