mongoid-elasticsearch 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -4
- data/README.md +1 -2
- data/lib/mongoid/elasticsearch/es.rb +10 -2
- data/lib/mongoid/elasticsearch/pagination.rb +1 -1
- data/lib/mongoid/elasticsearch/response.rb +1 -1
- data/lib/mongoid/elasticsearch/version.rb +1 -1
- data/spec/mongoid_elasticsearch_spec.rb +14 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fe059b63d7362ec40846b313bbd295c00c241d5
|
4
|
+
data.tar.gz: cd8078c6a3ab9f84c47c6e7bfafb2e10ba2a58a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d4f1dc1f2cf58b1f31823353de26bcee60ef058645d1e610e816a987ceb2b295cf341b7a3d4d9243bbb812df6dcdf7e516ef199ff05863e1104eee2f5111f31
|
7
|
+
data.tar.gz: 64af9b66fa3977519d375b2533a5f33b920acb7203b87edea9bd84aa2eab3b29c843faf8242917b16819af92d0db52c5571189874a0bb4fdea65f8ec5b0cd1b8
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/rs-pro/mongoid-elasticsearch.png?branch=master)](https://travis-ci.org/rs-pro/mongoid-elasticsearch)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/rs-pro/mongoid-elasticsearch/badge.png?branch=master)](https://coveralls.io/r/rs-pro/mongoid-elasticsearch?branch=master)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/mongoid-elasticsearch.png)](http://badge.fury.io/rb/mongoid-elasticsearch)
|
6
|
-
[![Dependency Status](https://
|
7
|
-
|
6
|
+
[![Dependency Status](https://www.versioneye.com/ruby/mongoid-elasticsearch/0.8.2/badge.svg)](https://www.versioneye.com/ruby/mongoid-elasticsearch/0.8.2)
|
8
7
|
|
9
8
|
Use [Elasticsearch](http://www.elasticsearch.org/) with mongoid with just a few
|
10
9
|
lines of code
|
@@ -45,14 +45,14 @@ module Mongoid
|
|
45
45
|
end
|
46
46
|
|
47
47
|
page = options[:page]
|
48
|
-
per_page = options[:per_page]
|
48
|
+
per_page = options[:per_page].nil? ? options[:per] : options[:per_page]
|
49
49
|
|
50
50
|
query[:size] = ( per_page.to_i ) if per_page
|
51
51
|
query[:from] = ( page.to_i <= 1 ? 0 : (per_page.to_i * (page.to_i-1)) ) if page && per_page
|
52
52
|
|
53
53
|
options[:wrapper] ||= klass.es_wrapper
|
54
54
|
|
55
|
-
Response.new(client, query.merge(
|
55
|
+
Response.new(client, query.merge(custom_type_options(options)), false, klass, options)
|
56
56
|
end
|
57
57
|
|
58
58
|
def all(options = {})
|
@@ -63,6 +63,14 @@ module Mongoid
|
|
63
63
|
{id: obj.id.to_s}.merge type_options
|
64
64
|
end
|
65
65
|
|
66
|
+
def custom_type_options(options)
|
67
|
+
if !options[:include_type].nil? && options[:include_type] == false
|
68
|
+
{index: index.name}
|
69
|
+
else
|
70
|
+
type_options
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
66
74
|
def type_options
|
67
75
|
{index: index.name, type: index.type}
|
68
76
|
end
|
@@ -104,7 +104,7 @@ module Mongoid
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def inspect
|
107
|
-
"#<Mongoid::Elasticsearch::Response @size:#{size} @results:#{results.inspect} @
|
107
|
+
"#<Mongoid::Elasticsearch::Response @size:#{@results.nil? ? 'not run yet' : size} @results:#{@results.inspect} @raw_response=#{@raw_response}>"
|
108
108
|
end
|
109
109
|
|
110
110
|
def count
|
@@ -126,7 +126,6 @@ describe Article do
|
|
126
126
|
|
127
127
|
it 'paging works with empty results' do
|
128
128
|
result = Article.es.search('bad_request', per_page: 7, page: 1)
|
129
|
-
p result
|
130
129
|
expect(result.num_pages).to eq 0
|
131
130
|
expect(result.current_page).to eq 1
|
132
131
|
expect(result.total_entries).to eq 0
|
@@ -354,6 +353,20 @@ describe Namespaced::Model do
|
|
354
353
|
expect(results.first.id).to eq @article_2.id
|
355
354
|
expect(results.first.name).to eq @article_2.name
|
356
355
|
end
|
356
|
+
|
357
|
+
it 'searches in field' do
|
358
|
+
results = Namespaced::Model.es.search body: {query: {terms: {name: ['likely']}}}
|
359
|
+
expect(results.count).to eq 1
|
360
|
+
expect(results.to_a.count).to eq 1
|
361
|
+
expect(results.first.id).to eq @article_2.id
|
362
|
+
expect(results.first.name).to eq @article_2.name
|
363
|
+
end
|
364
|
+
|
365
|
+
it 'searches in field - when no match' do
|
366
|
+
results = Namespaced::Model.es.search body: {query: {terms: {name: ['not_matched']}}}
|
367
|
+
expect(results.count).to eq 0
|
368
|
+
expect(results.to_a.count).to eq 0
|
369
|
+
end
|
357
370
|
end
|
358
371
|
|
359
372
|
context 'pagination' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|