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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ab2a507244af6596bf9c5770642ff8e0437018d
4
- data.tar.gz: 7cc3aa09ebab9cf69d471ddab31ec2f3f6e041ad
3
+ metadata.gz: 0fe059b63d7362ec40846b313bbd295c00c241d5
4
+ data.tar.gz: cd8078c6a3ab9f84c47c6e7bfafb2e10ba2a58a4
5
5
  SHA512:
6
- metadata.gz: a3f54a1d33748829d1bd94f5ac9c05ffb0c926a217e2568de570a45225cff7bf30a53a964c9bed295c2391fb679706196e76338137b90110bf0f2d12ef7679fa
7
- data.tar.gz: e878bfa26f9274669d554914be9a462d34f0d55dc607ea48aa4c875a4bd2cc4471ae28f4038a8692444294a3160fd686b01cb3b3ed0e08308c8ea3b6209adc7c
6
+ metadata.gz: 9d4f1dc1f2cf58b1f31823353de26bcee60ef058645d1e610e816a987ceb2b295cf341b7a3d4d9243bbb812df6dcdf7e516ef199ff05863e1104eee2f5111f31
7
+ data.tar.gz: 64af9b66fa3977519d375b2533a5f33b920acb7203b87edea9bd84aa2eab3b29c843faf8242917b16819af92d0db52c5571189874a0bb4fdea65f8ec5b0cd1b8
data/.travis.yml CHANGED
@@ -7,11 +7,10 @@ notifications:
7
7
 
8
8
  language: ruby
9
9
  rvm:
10
- - 2.0.0
11
- - 2.1.1
12
- - jruby-20mode
10
+ - 2.1.2
11
+ - jruby-head
13
12
 
14
13
  gemfile:
15
14
  - Gemfile
16
15
  - gemfiles/mongoid3.gemfile
17
- - gemfiles/es-git.gemfile
16
+
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://gemnasium.com/rs-pro/mongoid-elasticsearch.png)](https://gemnasium.com/rs-pro/mongoid-elasticsearch)
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(type_options), false, klass, options)
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
@@ -10,7 +10,7 @@ module Mongoid
10
10
  end
11
11
 
12
12
  def per_page
13
- (@options[:per_page] || @options[:size] || 10 ).to_i
13
+ (@options[:per_page] || @options[:per] || @options[:size] || 10 ).to_i
14
14
  end
15
15
 
16
16
  def total_pages
@@ -104,7 +104,7 @@ module Mongoid
104
104
  end
105
105
 
106
106
  def inspect
107
- "#<Mongoid::Elasticsearch::Response @size:#{size} @results:#{results.inspect} @error=#{success? ? "none" : error} @raw_response=#{raw_response}>"
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
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Elasticsearch
3
- VERSION = "0.8.2"
3
+ VERSION = "0.8.3"
4
4
  end
5
5
  end
@@ -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.2
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-06-26 00:00:00.000000000 Z
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid