chewy_queries 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46359b95123b84264bb61b3ce21c2ecc9375bb5cc45c0df5d36a398bc6762ae8
4
- data.tar.gz: 7c322211d19b5412a143ea5dd2d88fa93b3c018b73aefcca7f41ef5e8d74c03f
3
+ metadata.gz: add0b2391e69e66947d7323c8f296e53275d4b5d6a179ad2fbc800115908493f
4
+ data.tar.gz: ae14f4c97ab71d2ea790992dc8b9396271f9b0278ee236456b85df4f09f306de
5
5
  SHA512:
6
- metadata.gz: 750cc3e95af36b4d07521b59b6c60547fc6274421861e38cd4afcb7f44df7e3057e2b51b370a1dbcbcb8dcf5012a16f70ad1084ac306531bfd9280d71a186bce
7
- data.tar.gz: 1d83fc2833cc6a6f10f9e02d1a8b9852b3786f42cb3d1cf5a64b06489858af895b92b68be2ec35139b23d56773eddcfc81cd79f2cb1cfe9c0edaa5450544ebbe
6
+ metadata.gz: 548ed26e5bc14e219371e15d74e405346965bb486f4604b49ef2da9af98cd1a7eb0f5fc0952da1c982efec5367be657cceeb24a8c876f4248e52b5af099395d2
7
+ data.tar.gz: c0ab9fa4fd9f8933c8731be3386af093423d97a9c8739d19ea3cc4a99d1b2f6dd3373cc2eec95d7902dd40200d15426ad7f29761f4bd146094aeb7bcc5cc79cb
data/README.md CHANGED
@@ -21,13 +21,13 @@ require 'chewy_queries'
21
21
 
22
22
  This gem requires Ruby 2.4+, Rails 5.0+ and Chewy 5.2.0
23
23
 
24
- ### Search query requires the following
24
+ ## Search query requires the following
25
25
 
26
- #def ChewyQueries.search(class_name, type, condition, value, field)
27
- ------
28
- ------
29
- ------
30
- #end
26
+ ## def ChewyQueries.search(class_name, type, condition, value, field)
27
+ # some elastic queries
28
+ ## end
29
+
30
+ Above method includes all possible query to get the search result.
31
31
 
32
32
  ## class_name should be your index class name
33
33
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.platform = Gem::Platform::RUBY
12
12
  spec.required_ruby_version = '>= 2.4.0'
13
13
  spec.files = Dir['README.md', 'LICENSE',
14
- 'CHANGELOG.md', 'lib/**/*.rb',
14
+ 'CHANGELOG.md', 'lib/**/*.rb','lib/chewy_queries.rb',
15
15
  'lib/**/*.rake',
16
16
  'chewy_queries.gemspec', '.github/*.md',
17
17
  'Gemfile', 'Rakefile']
data/lib/chewy_queries.rb CHANGED
@@ -65,5 +65,23 @@ class ChewyQueries
65
65
  end
66
66
  end
67
67
 
68
+ def self.exact_match_search(class_name, field, value)
69
+ class_name.query(match_phrase: {"#{field}": value}).to_a
70
+ end
71
+
72
+ def self.partial_search(class_name, field, value)
73
+ class_name.query(regexp: {"#{field}": ".*#{value.downcase}.*"}).to_a
74
+ end
75
+
76
+ def self.multiple_field_search(class_name, multiple_field_array, value)
77
+ exact_search = []
78
+ partial_search = []
79
+ multiple_field_array.each do |field|
80
+ exact_search << class_name.query(match_phrase: {"#{field}": value}).to_a
81
+ partial_search << class_name.query(regexp: {"#{field}": ".*#{value.downcase}.*"}).to_a
82
+ end
83
+ search = exact_search + partial_search
84
+ return search.uniq
85
+ end
68
86
 
69
87
  end
@@ -1,3 +1,3 @@
1
1
  module ChewyQueries
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chewy_queries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rakesh