typesense 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/examples/client_initialization.rb +4 -4
- data/examples/search.rb +22 -57
- data/lib/typesense.rb +1 -0
- data/lib/typesense/client.rb +3 -1
- data/lib/typesense/multi_search.rb +15 -0
- data/lib/typesense/version.rb +1 -1
- data/typesense.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47b1bddb975dd2055704e6184451e05a2e9fd05585021068f788610963044ebd
|
4
|
+
data.tar.gz: 326c4515546569fdc3bc01b5681369aa75a1242ae112f1e7f40b36320ec56d20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64918475f966d9fdc1625c25a5e6c9273dc88a71ca8b3cbe3fed2d4387cc58c694fc0d6285588c55c960353e3bf2782df3ef36ff4e1cccd4633d47740b81f482
|
7
|
+
data.tar.gz: d9f8381fba8ffcfa82034fe5f62d3f176a7a8485876848ea75dd2cfde7798483a909c756acc5670ae18fd876f6bc570943ccc986d56e5816fa7f6abc8f1b645f
|
data/README.md
CHANGED
@@ -33,6 +33,7 @@ Tests are also a good place to know how the the library works internally: [spec]
|
|
33
33
|
|
34
34
|
| Typesense Server | typesense-ruby |
|
35
35
|
|------------------|----------------|
|
36
|
+
| \>= v0.19.0 | \>= v0.11.0 |
|
36
37
|
| \>= v0.18.0 | \>= v0.10.0 |
|
37
38
|
| \>= v0.17.0 | \>= v0.9.0 |
|
38
39
|
| \>= v0.16.0 | \>= v0.8.0 |
|
@@ -12,7 +12,7 @@ AwesomePrint.defaults = {
|
|
12
12
|
## Setup
|
13
13
|
#
|
14
14
|
### Option 1: Start a single-node cluster
|
15
|
-
# $ docker run -i -p 8108:8108 -v/tmp/typesense-server-data-1b/:/data -v`pwd`/typesense-server-peers:/typesense-server-peers typesense/typesense:0.
|
15
|
+
# $ docker run -i -p 8108:8108 -v/tmp/typesense-server-data-1b/:/data -v`pwd`/typesense-server-peers:/typesense-server-peers typesense/typesense:0.19.0 --data-dir /data --api-key=xyz --listen-port 8108 --enable-cors
|
16
16
|
#
|
17
17
|
### Option 2: Start a 3-node cluster
|
18
18
|
#
|
@@ -20,13 +20,13 @@ AwesomePrint.defaults = {
|
|
20
20
|
# $ echo '172.17.0.2:8107:8108,172.17.0.3:7107:7108,172.17.0.4:9107:9108' > `pwd`/typesense-server-peers
|
21
21
|
#
|
22
22
|
# Start node 1:
|
23
|
-
# $ docker run -i -p 8108:8108 -p 8107:8107 -v/tmp/typesense-server-data-1b/:/data -v`pwd`/typesense-server-peers:/typesense-server-peers typesense/typesense:0.
|
23
|
+
# $ docker run -i -p 8108:8108 -p 8107:8107 -v/tmp/typesense-server-data-1b/:/data -v`pwd`/typesense-server-peers:/typesense-server-peers typesense/typesense:0.19.0 --data-dir /data --api-key=xyz --listen-port 8108 --peering-port 8107 --enable-cors --nodes=/typesense-server-peers
|
24
24
|
#
|
25
25
|
# Start node 2:
|
26
|
-
# $ docker run -i -p 7108:7108 -p 7107:7107 -v/tmp/.typesense-server-data-2b/:/data -v`pwd`/typesense-server-peers:/typesense-server-peers typesense/typesense:0.
|
26
|
+
# $ docker run -i -p 7108:7108 -p 7107:7107 -v/tmp/.typesense-server-data-2b/:/data -v`pwd`/typesense-server-peers:/typesense-server-peers typesense/typesense:0.19.0 --data-dir /data --api-key=xyz --listen-port 7108 --peering-port 7107 --enable-cors --nodes=/typesense-server-peers
|
27
27
|
#
|
28
28
|
# Start node 3:
|
29
|
-
# $ docker run -i -p 9108:9108 -p 9107:9107 -v/tmp/.typesense-server-data-3b/:/data -v`pwd`/typesense-server-peers:/typesense-server-peers typesense/typesense:0.
|
29
|
+
# $ docker run -i -p 9108:9108 -p 9107:9107 -v/tmp/.typesense-server-data-3b/:/data -v`pwd`/typesense-server-peers:/typesense-server-peers typesense/typesense:0.19.0 --data-dir /data --api-key=xyz --listen-port 9108 --peering-port 9107 --enable-cors --nodes=/typesense-server-peers
|
30
30
|
#
|
31
31
|
# Note: Be sure to add `--license-key=<>` at the end when starting a Typesense Premium server
|
32
32
|
|
data/examples/search.rb
CHANGED
@@ -73,37 +73,6 @@ results = @typesense.collections['companies'].documents.search(
|
|
73
73
|
)
|
74
74
|
ap results
|
75
75
|
|
76
|
-
# {
|
77
|
-
# "facet_counts" => [],
|
78
|
-
# "found" => 2,
|
79
|
-
# "hits" => [
|
80
|
-
# [0] {
|
81
|
-
# "document" => {
|
82
|
-
# "company_name" => "Stark Industries",
|
83
|
-
# "country" => "USA",
|
84
|
-
# "id" => "124",
|
85
|
-
# "num_employees" => 5215
|
86
|
-
# },
|
87
|
-
# "highlight" => {
|
88
|
-
# "company_name" => "<mark>Stark</mark> Industries"
|
89
|
-
# }
|
90
|
-
# },
|
91
|
-
# [1] {
|
92
|
-
# "document" => {
|
93
|
-
# "company_name" => "Stark Corp",
|
94
|
-
# "country" => "USA",
|
95
|
-
# "id" => "127",
|
96
|
-
# "num_employees" => 1031
|
97
|
-
# },
|
98
|
-
# "highlight" => {
|
99
|
-
# "company_name" => "<mark>Stark</mark> Corp"
|
100
|
-
# }
|
101
|
-
# }
|
102
|
-
# ],
|
103
|
-
# "page" => 1,
|
104
|
-
# "search_time_ms" => 0
|
105
|
-
# }
|
106
|
-
|
107
76
|
##
|
108
77
|
# Search for more documents
|
109
78
|
results = @typesense.collections['companies'].documents.search(
|
@@ -114,25 +83,28 @@ results = @typesense.collections['companies'].documents.search(
|
|
114
83
|
)
|
115
84
|
ap results
|
116
85
|
|
117
|
-
|
118
|
-
#
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
#
|
134
|
-
|
135
|
-
|
86
|
+
##
|
87
|
+
# Search for more multiple documents
|
88
|
+
results = @typesense.multi_search.perform(
|
89
|
+
{
|
90
|
+
searches: [
|
91
|
+
{
|
92
|
+
'q' => 'Inc',
|
93
|
+
'filter_by' => 'num_employees:<100',
|
94
|
+
'sort_by' => 'num_employees:desc'
|
95
|
+
},
|
96
|
+
{
|
97
|
+
'q' => 'Stark'
|
98
|
+
}
|
99
|
+
]
|
100
|
+
},
|
101
|
+
{
|
102
|
+
# Parameters that are common to all searches, can be mentioned here
|
103
|
+
'collection' => 'companies',
|
104
|
+
'query_by' => 'company_name'
|
105
|
+
}
|
106
|
+
)
|
107
|
+
ap results
|
136
108
|
|
137
109
|
##
|
138
110
|
# Search for more documents
|
@@ -142,13 +114,6 @@ results = @typesense.collections['companies'].documents.search(
|
|
142
114
|
)
|
143
115
|
ap results
|
144
116
|
|
145
|
-
# {
|
146
|
-
# "found" => 0,
|
147
|
-
# "hits" => [],
|
148
|
-
# "page" => 1,
|
149
|
-
# "search_time_ms" => 0
|
150
|
-
# }
|
151
|
-
|
152
117
|
##
|
153
118
|
# Cleanup
|
154
119
|
# Drop the collection
|
data/lib/typesense.rb
CHANGED
@@ -19,6 +19,7 @@ require_relative 'typesense/aliases'
|
|
19
19
|
require_relative 'typesense/alias'
|
20
20
|
require_relative 'typesense/keys'
|
21
21
|
require_relative 'typesense/key'
|
22
|
+
require_relative 'typesense/multi_search'
|
22
23
|
require_relative 'typesense/debug'
|
23
24
|
require_relative 'typesense/health'
|
24
25
|
require_relative 'typesense/metrics'
|
data/lib/typesense/client.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
module Typesense
|
4
4
|
class Client
|
5
|
-
attr_reader :configuration, :collections, :aliases, :keys, :debug, :health, :metrics, :operations
|
5
|
+
attr_reader :configuration, :collections, :aliases, :keys, :debug, :health, :metrics, :operations,
|
6
|
+
:multi_search
|
6
7
|
|
7
8
|
def initialize(options = {})
|
8
9
|
@configuration = Configuration.new(options)
|
@@ -10,6 +11,7 @@ module Typesense
|
|
10
11
|
@collections = Collections.new(@api_call)
|
11
12
|
@aliases = Aliases.new(@api_call)
|
12
13
|
@keys = Keys.new(@api_call)
|
14
|
+
@multi_search = MultiSearch.new(@api_call)
|
13
15
|
@debug = Debug.new(@api_call)
|
14
16
|
@health = Health.new(@api_call)
|
15
17
|
@metrics = Metrics.new(@api_call)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Typesense
|
4
|
+
class MultiSearch
|
5
|
+
RESOURCE_PATH = '/multi_search'
|
6
|
+
|
7
|
+
def initialize(api_call)
|
8
|
+
@api_call = api_call
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform(searches, query_params = {})
|
12
|
+
@api_call.post(RESOURCE_PATH, searches, query_params)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/typesense/version.rb
CHANGED
data/typesense.gemspec
CHANGED
@@ -40,6 +40,6 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency 'timecop', '~> 0.9'
|
41
41
|
spec.add_development_dependency 'webmock', '~> 3.8'
|
42
42
|
|
43
|
-
spec.add_dependency 'oj', '~> 3.
|
43
|
+
spec.add_dependency 'oj', '~> 3.11'
|
44
44
|
spec.add_dependency 'typhoeus', '~> 1.4'
|
45
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typesense
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Typesense, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: '3.
|
229
|
+
version: '3.11'
|
230
230
|
type: :runtime
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: '3.
|
236
|
+
version: '3.11'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: typhoeus
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -291,6 +291,7 @@ files:
|
|
291
291
|
- lib/typesense/key.rb
|
292
292
|
- lib/typesense/keys.rb
|
293
293
|
- lib/typesense/metrics.rb
|
294
|
+
- lib/typesense/multi_search.rb
|
294
295
|
- lib/typesense/operations.rb
|
295
296
|
- lib/typesense/override.rb
|
296
297
|
- lib/typesense/overrides.rb
|