algoliasearch-rails 1.17.1 → 1.18.0
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.
- checksums.yaml +13 -5
- data/.travis.yml +3 -0
- data/ChangeLog +4 -0
- data/Gemfile +12 -2
- data/README.md +53 -61
- data/VERSION +1 -1
- data/lib/algoliasearch-rails.rb +15 -6
- metadata +22 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
NzJhNzkwMzY2NzdkNDAzOTBmY2EyNDU4N2FmYzJiMDlkMTVhYzE4NA==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
ZjBkYjBkOGJiODAwMjM4MzI3YTU4MWEwNGI1NmJlYWM1MzhmNjFiMA==
|
|
5
7
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
YmYwYmU4NTcwMmE1YWZmMWZkOTZjODU5MzhlYWExY2U0ZmFlMmQxNDg5MjFk
|
|
10
|
+
NWY3NmRmMzY5ZTU5MWJjY2Y4ZDgyN2IxM2MxMjc3NzBiZWVkYTFlZTEzYjM4
|
|
11
|
+
YmMxZWU2MmI3ZmQ1NTRhNmQ1YjJiMWVjYmZmOTFhZmIyOTg3MDM=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
YjZhMWQ0YzU0NmQ2YTkwYTYwYzFlNDg1ODdjMjBmMmNiY2RlMmViNTViOGY2
|
|
14
|
+
NGFkOGQ4Y2QyNzhjZGNkNDJjNDZlYjY3MTAyZGZjYTY4YmNhMzI2YTQzODg4
|
|
15
|
+
OWE0NjBlZTdiMmJkYjZlNzVkYmM5MzM2YjU0NTcxNzFjYmJiN2U=
|
data/.travis.yml
CHANGED
data/ChangeLog
CHANGED
data/Gemfile
CHANGED
|
@@ -2,7 +2,10 @@ source "http://rubygems.org"
|
|
|
2
2
|
|
|
3
3
|
gem 'json', '~> 1.5', '>= 1.5.1'
|
|
4
4
|
gem 'algoliasearch', '~> 1.12.4'
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
|
7
|
+
gem 'rubysl', '~> 2.0', :platform => :rbx
|
|
8
|
+
end
|
|
6
9
|
|
|
7
10
|
group :test do
|
|
8
11
|
rails_version = ENV["RAILS_VERSION"] ? "~> #{ENV["RAILS_VERSION"]}" : '>= 3.2.0'
|
|
@@ -47,5 +50,12 @@ end
|
|
|
47
50
|
|
|
48
51
|
group :test, :development do
|
|
49
52
|
gem 'will_paginate', '>= 2.3.15'
|
|
50
|
-
|
|
53
|
+
if defined?(RUBY_VERSION) &&
|
|
54
|
+
defined?(RUBY_ENGINE) &&
|
|
55
|
+
RUBY_ENGINE == 'ruby' &&
|
|
56
|
+
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2')
|
|
57
|
+
gem 'kaminari', '< 1'
|
|
58
|
+
else
|
|
59
|
+
gem 'kaminari'
|
|
60
|
+
end
|
|
51
61
|
end
|
data/README.md
CHANGED
|
@@ -2,86 +2,76 @@
|
|
|
2
2
|
|
|
3
3
|
[Algolia Search](https://www.algolia.com) is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://travis-ci.org/algolia/algoliasearch-rails) [](http://badge.fury.io/rb/algoliasearch-rails) [](https://codeclimate.com/github/algolia/algoliasearch-rails)   
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
This gem let you easily integrate the Algolia Search API to your favorite ORM. It's based on the [algoliasearch-client-ruby](https://github.com/algolia/algoliasearch-client-ruby) gem.
|
|
9
|
+
Rails 3.x, 4.x and 5.x are all supported.
|
|
6
10
|
|
|
7
11
|
You might be interested in the sample Ruby on Rails application providing a `autocomplete.js`-based auto-completion and `instantsearch.js`-based instant search results page: [algoliasearch-rails-example](https://github.com/algolia/algoliasearch-rails-example/).
|
|
8
12
|
|
|
9
|
-
[](https://travis-ci.org/algolia/algoliasearch-rails) [](http://badge.fury.io/rb/algoliasearch-rails) [](https://codeclimate.com/github/algolia/algoliasearch-rails)   
|
|
10
13
|
|
|
11
14
|
|
|
12
|
-
**Note:** An easier-to-read version of this documentation is available on
|
|
13
|
-
[Algolia's website](https://www.algolia.com/doc/api-client/rails/).
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
## API Documentation
|
|
17
|
+
|
|
18
|
+
You can find the full reference on [Algolia's website](https://www.algolia.com/doc/api-client/rails/).
|
|
16
19
|
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
## Table of Contents
|
|
19
22
|
|
|
20
|
-
1. [Install](#install)
|
|
21
|
-
1. [Configuration](#configuration)
|
|
22
|
-
1. [Timeouts](#timeouts)
|
|
23
|
-
1. [Notes](#notes)
|
|
24
23
|
|
|
25
|
-
**
|
|
24
|
+
1. **[Setup](#setup)**
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
1. [Backend Search](#backend-search)
|
|
32
|
-
1. [Backend Pagination](#backend-pagination)
|
|
33
|
-
1. [Tags](#tags)
|
|
34
|
-
1. [Faceting](#faceting)
|
|
35
|
-
1. [Faceted search](#faceted-search)
|
|
36
|
-
1. [Group by](#group-by)
|
|
37
|
-
1. [Geo-Search](#geo-search)
|
|
26
|
+
* [Install](#install)
|
|
27
|
+
* [Configuration](#configuration)
|
|
28
|
+
* [Timeouts](#timeouts)
|
|
29
|
+
* [Notes](#notes)
|
|
38
30
|
|
|
39
|
-
**
|
|
31
|
+
1. **[Usage](#usage)**
|
|
40
32
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
* [Index Schema](#index-schema)
|
|
34
|
+
* [Relevancy](#relevancy)
|
|
35
|
+
* [Indexing](#indexing)
|
|
36
|
+
* [Frontend Search (realtime experience)](#frontend-search-realtime-experience)
|
|
37
|
+
* [Backend Search](#backend-search)
|
|
38
|
+
* [Backend Pagination](#backend-pagination)
|
|
39
|
+
* [Tags](#tags)
|
|
40
|
+
* [Faceting](#faceting)
|
|
41
|
+
* [Faceted search](#faceted-search)
|
|
42
|
+
* [Group by](#group-by)
|
|
43
|
+
* [Geo-Search](#geo-search)
|
|
52
44
|
|
|
53
|
-
**
|
|
45
|
+
1. **[Options](#options)**
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
* [Auto-indexing & asynchronism](#auto-indexing--asynchronism)
|
|
48
|
+
* [Custom index name](#custom-index-name)
|
|
49
|
+
* [Per-environment indices](#per-environment-indices)
|
|
50
|
+
* [Custom attribute definition](#custom-attribute-definition)
|
|
51
|
+
* [Nested objects/relations](#nested-objectsrelations)
|
|
52
|
+
* [Custom `objectID`](#custom-objectid)
|
|
53
|
+
* [Restrict indexing to a subset of your data](#restrict-indexing-to-a-subset-of-your-data)
|
|
54
|
+
* [Sanitizer](#sanitizer)
|
|
55
|
+
* [UTF-8 Encoding](#utf-8-encoding)
|
|
56
|
+
* [Exceptions](#exceptions)
|
|
57
|
+
* [Configuration example](#configuration-example)
|
|
63
58
|
|
|
64
|
-
**
|
|
59
|
+
1. **[Indices](#indices)**
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
* [Manual indexing](#manual-indexing)
|
|
62
|
+
* [Manual removal](#manual-removal)
|
|
63
|
+
* [Reindexing](#reindexing)
|
|
64
|
+
* [Clearing an index](#clearing-an-index)
|
|
65
|
+
* [Using the underlying index](#using-the-underlying-index)
|
|
66
|
+
* [Primary/replica](#primaryreplica)
|
|
67
|
+
* [Share a single index](#share-a-single-index)
|
|
68
|
+
* [Target multiple indices](#target-multiple-indices)
|
|
67
69
|
|
|
70
|
+
1. **[Testing](#testing)**
|
|
68
71
|
|
|
69
|
-
#
|
|
72
|
+
* [Notes](#notes)
|
|
70
73
|
|
|
71
|
-
Check our [online guides](https://www.algolia.com/doc):
|
|
72
74
|
|
|
73
|
-
* [Data Formatting](https://www.algolia.com/doc/indexing/formatting-your-data)
|
|
74
|
-
* [Import and Synchronize data](https://www.algolia.com/doc/indexing/import-synchronize-data/php)
|
|
75
|
-
* [Autocomplete](https://www.algolia.com/doc/search/auto-complete)
|
|
76
|
-
* [Instant search page](https://www.algolia.com/doc/search/instant-search)
|
|
77
|
-
* [Filtering and Faceting](https://www.algolia.com/doc/search/filtering-faceting)
|
|
78
|
-
* [Sorting](https://www.algolia.com/doc/relevance/sorting)
|
|
79
|
-
* [Ranking Formula](https://www.algolia.com/doc/relevance/ranking)
|
|
80
|
-
* [Typo-Tolerance](https://www.algolia.com/doc/relevance/typo-tolerance)
|
|
81
|
-
* [Geo-Search](https://www.algolia.com/doc/geo-search/geo-search-overview)
|
|
82
|
-
* [Security](https://www.algolia.com/doc/security/best-security-practices)
|
|
83
|
-
* [API-Keys](https://www.algolia.com/doc/security/api-keys)
|
|
84
|
-
* [REST API](https://www.algolia.com/doc/rest)
|
|
85
75
|
|
|
86
76
|
|
|
87
77
|
# Setup
|
|
@@ -922,7 +912,8 @@ index = Contact.index
|
|
|
922
912
|
|
|
923
913
|
## Primary/replica
|
|
924
914
|
|
|
925
|
-
You can define replica indices using the <code>add_replica</code> method
|
|
915
|
+
You can define replica indices using the <code>add_replica</code> method.
|
|
916
|
+
Use `inherit: true` on the replica block if you want it to inherit from the primary settings.
|
|
926
917
|
|
|
927
918
|
```ruby
|
|
928
919
|
class Book < ActiveRecord::Base
|
|
@@ -939,7 +930,7 @@ class Book < ActiveRecord::Base
|
|
|
939
930
|
end
|
|
940
931
|
|
|
941
932
|
# define a replica index to search by `editor` only
|
|
942
|
-
add_replica 'Book_by_editor', per_environment: true do
|
|
933
|
+
add_replica 'Book_by_editor', inherit: true, per_environment: true do
|
|
943
934
|
searchableAttributes [:editor]
|
|
944
935
|
end
|
|
945
936
|
end
|
|
@@ -1087,3 +1078,4 @@ end
|
|
|
1087
1078
|
```
|
|
1088
1079
|
|
|
1089
1080
|
|
|
1081
|
+
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.18.0
|
data/lib/algoliasearch-rails.rb
CHANGED
|
@@ -256,13 +256,13 @@ module AlgoliaSearch
|
|
|
256
256
|
def add_replica(index_name, options = {}, &block)
|
|
257
257
|
raise ArgumentError.new('Cannot specify additional replicas on a replica index') if @options[:slave] || @options[:replica]
|
|
258
258
|
raise ArgumentError.new('No block given') if !block_given?
|
|
259
|
-
add_index(index_name, options.merge({ :replica => true }), &block)
|
|
259
|
+
add_index(index_name, options.merge({ :replica => true, :primary_settings => self }), &block)
|
|
260
260
|
end
|
|
261
261
|
|
|
262
262
|
def add_slave(index_name, options = {}, &block)
|
|
263
263
|
raise ArgumentError.new('Cannot specify additional slaves on a slave index') if @options[:slave] || @options[:replica]
|
|
264
264
|
raise ArgumentError.new('No block given') if !block_given?
|
|
265
|
-
add_index(index_name, options.merge({ :slave => true }), &block)
|
|
265
|
+
add_index(index_name, options.merge({ :slave => true, :primary_settings => self }), &block)
|
|
266
266
|
end
|
|
267
267
|
|
|
268
268
|
def additional_indexes
|
|
@@ -308,7 +308,7 @@ module AlgoliaSearch
|
|
|
308
308
|
begin
|
|
309
309
|
@index.get_settings(*args)
|
|
310
310
|
rescue Algolia::AlgoliaError => e
|
|
311
|
-
return {} if e.
|
|
311
|
+
return {} if e.code == 404 # not fatal
|
|
312
312
|
raise e
|
|
313
313
|
end
|
|
314
314
|
end
|
|
@@ -725,22 +725,31 @@ module AlgoliaSearch
|
|
|
725
725
|
|
|
726
726
|
def algolia_ensure_init(options = nil, settings = nil, index_settings = nil)
|
|
727
727
|
raise ArgumentError.new('No `algoliasearch` block found in your model.') if algoliasearch_settings.nil?
|
|
728
|
+
|
|
728
729
|
@algolia_indexes ||= {}
|
|
730
|
+
|
|
729
731
|
options ||= algoliasearch_options
|
|
730
732
|
settings ||= algoliasearch_settings
|
|
733
|
+
|
|
731
734
|
return @algolia_indexes[settings] if @algolia_indexes[settings]
|
|
735
|
+
|
|
732
736
|
@algolia_indexes[settings] = SafeIndex.new(algolia_index_name(options), algoliasearch_options[:raise_on_failure])
|
|
737
|
+
|
|
733
738
|
current_settings = @algolia_indexes[settings].get_settings rescue nil # if the index doesn't exist
|
|
734
|
-
|
|
735
|
-
|
|
739
|
+
|
|
740
|
+
index_settings ||= settings.to_settings
|
|
741
|
+
index_settings = options[:primary_settings].to_settings.merge(index_settings) if options[:inherit]
|
|
742
|
+
|
|
743
|
+
if !algolia_indexing_disabled?(options) && (index_settings || algoliasearch_settings_changed?(current_settings, index_settings))
|
|
736
744
|
used_slaves = !current_settings.nil? && !current_settings['slaves'].nil?
|
|
737
745
|
replicas = index_settings.delete(:replicas) ||
|
|
738
746
|
index_settings.delete('replicas') ||
|
|
739
747
|
index_settings.delete(:slaves) ||
|
|
740
748
|
index_settings.delete('slaves')
|
|
741
|
-
index_settings[used_slaves ? :slaves : :replicas] = replicas
|
|
749
|
+
index_settings[used_slaves ? :slaves : :replicas] = replicas unless replicas.nil? || options[:inherit]
|
|
742
750
|
@algolia_indexes[settings].set_settings(index_settings)
|
|
743
751
|
end
|
|
752
|
+
|
|
744
753
|
@algolia_indexes[settings]
|
|
745
754
|
end
|
|
746
755
|
|
metadata
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: algoliasearch-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Algolia
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-02-
|
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - ! '>='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 1.5.1
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - ! '>='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 1.5.1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: algoliasearch
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ~>
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: 1.12.4
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ~>
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: 1.12.4
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: will_paginate
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - ! '>='
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: 2.3.15
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - ! '>='
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: 2.3.15
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: kaminari
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - ! '>='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - ! '>='
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: travis
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
73
|
+
- - ! '>='
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- -
|
|
80
|
+
- - ! '>='
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: rake
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
|
-
- -
|
|
87
|
+
- - ! '>='
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
89
|
version: '0'
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
|
-
- -
|
|
94
|
+
- - ! '>='
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: rdoc
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
|
-
- -
|
|
101
|
+
- - ! '>='
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
103
|
version: '0'
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
|
-
- -
|
|
108
|
+
- - ! '>='
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
description: AlgoliaSearch integration to your favorite ORM
|
|
@@ -117,9 +117,9 @@ extra_rdoc_files:
|
|
|
117
117
|
- LICENSE
|
|
118
118
|
- README.md
|
|
119
119
|
files:
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
120
|
+
- .document
|
|
121
|
+
- .rspec
|
|
122
|
+
- .travis.yml
|
|
123
123
|
- ChangeLog
|
|
124
124
|
- Gemfile
|
|
125
125
|
- Gemfile.lock
|
|
@@ -173,17 +173,17 @@ require_paths:
|
|
|
173
173
|
- lib
|
|
174
174
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
175
|
requirements:
|
|
176
|
-
- -
|
|
176
|
+
- - ! '>='
|
|
177
177
|
- !ruby/object:Gem::Version
|
|
178
178
|
version: '0'
|
|
179
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
requirements:
|
|
181
|
-
- -
|
|
181
|
+
- - ! '>='
|
|
182
182
|
- !ruby/object:Gem::Version
|
|
183
183
|
version: '0'
|
|
184
184
|
requirements: []
|
|
185
185
|
rubyforge_project:
|
|
186
|
-
rubygems_version: 2.6.
|
|
186
|
+
rubygems_version: 2.6.10
|
|
187
187
|
signing_key:
|
|
188
188
|
specification_version: 4
|
|
189
189
|
summary: AlgoliaSearch integration to your favorite ORM
|