es_query_builder 2.0.6 → 2.0.8
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 +4 -4
- data/lib/fetch_es_data.rb +2 -2
- data/lib/indexer.rb +9 -14
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13b1b680537ad9eaa7be2bdffc58efbeba1c8973
|
4
|
+
data.tar.gz: 5ab39ce12c20563e0e038cf80850680a17fb8f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a7fc7e09a40467f963246f134d1331b2d753113ad8990863e542f53bbae2f8e29c5807d909e7d298b53f7fbc6b16ab8bee97e6172de0ea913e8599729cf5c9
|
7
|
+
data.tar.gz: ea63c911a3d5031f60c101ec572a445bb2fd38026590d3f592e41e23e2f75a4fc0b9ca9097165ea488e15c7431ba7a4f84d9eb7ac65db4adb7cd7618d066b99d
|
data/lib/fetch_es_data.rb
CHANGED
@@ -18,7 +18,7 @@ class FetchEsData
|
|
18
18
|
# @param extension [String] extension to Elastic seach path (eg. '_search', '_msearch')
|
19
19
|
# @return [String, Hash]
|
20
20
|
def fetch_shortlisted_data_from_es(query:, index_name:, type_name:, extension: '_search')
|
21
|
-
uri = URI("http://#{@search_host}:#{@search_port}/#{index_name}/#{
|
21
|
+
uri = URI("http://#{@search_host}:#{@search_port}/#{index_name}/#{extension}")
|
22
22
|
req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'})
|
23
23
|
req.body = "#{query.to_json}\n"
|
24
24
|
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
@@ -27,4 +27,4 @@ class FetchEsData
|
|
27
27
|
body = JSON.parse(res.body) rescue {}
|
28
28
|
return res.code, body
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
data/lib/indexer.rb
CHANGED
@@ -11,7 +11,7 @@ class Indexer
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# expects data in the form of
|
14
|
-
# [{update:{_index: index,
|
14
|
+
# [{update:{_index: index, _id: 23, data: {doc: data }}},{index: {_index: index2, _id: 28, data: data}}]
|
15
15
|
# @param data [Array] Data to be indexed
|
16
16
|
def bulk_index(data)
|
17
17
|
check_bulk_index_params(data)
|
@@ -24,25 +24,23 @@ class Indexer
|
|
24
24
|
|
25
25
|
# checks whether the record exists in the given index with given type and id
|
26
26
|
# @param index_name [String] name of the index
|
27
|
-
# @param type_name_name [String] name of the type
|
28
27
|
# @param id [String] doc_id
|
29
28
|
# @param parent_id [String] parent_id (optional)
|
30
29
|
# @return [True] if record found
|
31
30
|
# @return [False] if record not found
|
32
|
-
def record_exists?(index_name,
|
33
|
-
options_hash = generate_options_hash(index_name,
|
31
|
+
def record_exists?(index_name, id, parent_id = nil)
|
32
|
+
options_hash = generate_options_hash(index_name, id, parent_id)
|
34
33
|
@client.exists options_hash
|
35
34
|
end
|
36
35
|
|
37
36
|
# deletes the record if exists in the given index with given type and id,
|
38
37
|
# raises DocumentNotFoundException if record is not found
|
39
38
|
# @param index_name [String] name of the index
|
40
|
-
# @param index_type [String] name of the type
|
41
39
|
# @param id [String] doc_id
|
42
40
|
# @param parent_id [String] parent_id
|
43
|
-
def delete_record(index_name,
|
44
|
-
if record_exists?(index_name,
|
45
|
-
@client.delete generate_options_hash(index_name,
|
41
|
+
def delete_record(index_name, id, parent_id = nil)
|
42
|
+
if record_exists?(index_name, id, parent_id)
|
43
|
+
@client.delete generate_options_hash(index_name, id, parent_id)
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
@@ -97,20 +95,17 @@ class Indexer
|
|
97
95
|
|
98
96
|
# creates new index givem the mapping and settings in index_params_hash
|
99
97
|
# @param index_name [String] name of the index(with timestamp)
|
100
|
-
# @param index_type [String] name of the type
|
101
98
|
# @param index_params_hash, {settins:{},mappings:{}}
|
102
|
-
def create_index(index_name,
|
99
|
+
def create_index(index_name, index_params_hash)
|
103
100
|
@client.indices.create index: "#{index_name}",
|
104
|
-
type: "#{index_type}",
|
105
101
|
body: index_params_hash
|
106
102
|
end
|
107
103
|
|
108
104
|
private
|
109
105
|
|
110
|
-
def generate_options_hash(name,
|
106
|
+
def generate_options_hash(name, id, parent_id)
|
111
107
|
options_hash = {
|
112
108
|
index: name,
|
113
|
-
type: type,
|
114
109
|
id: id
|
115
110
|
}
|
116
111
|
options_hash[:parent] = parent_id if parent_id
|
@@ -123,4 +118,4 @@ class Indexer
|
|
123
118
|
raise "Record count should be less than #{Constants::MAX_BULK_INDEX_SIZE}" if count > Constants::MAX_BULK_INDEX_SIZE
|
124
119
|
end
|
125
120
|
|
126
|
-
end
|
121
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: es_query_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohib Yousuf
|
8
8
|
- Anurag Agrawal
|
9
9
|
- Supantha Samanta
|
10
10
|
- Neeraj Joshi
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2024-07-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
- - '='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 3.5.0
|
78
|
-
description:
|
78
|
+
description:
|
79
79
|
email:
|
80
80
|
- mohib.yousuf@hotmail.com
|
81
81
|
- anuragagrawal117@gmail.com
|
@@ -170,7 +170,7 @@ homepage: https://github.com/elarahq/es.query.builder
|
|
170
170
|
licenses:
|
171
171
|
- MIT
|
172
172
|
metadata: {}
|
173
|
-
post_install_message:
|
173
|
+
post_install_message:
|
174
174
|
rdoc_options: []
|
175
175
|
require_paths:
|
176
176
|
- lib
|
@@ -185,9 +185,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
rubyforge_project:
|
188
|
+
rubyforge_project:
|
189
189
|
rubygems_version: 2.6.11
|
190
|
-
signing_key:
|
190
|
+
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: For Building Elastic Search Queries
|
193
193
|
test_files: []
|