chewy_queries 0.0.0 → 0.0.1

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: 0c6d1885ab06955770811de931724b92c66e7e8d8dd09ae1359aa8b3cef49b2a
4
- data.tar.gz: 7055330aeaf2319035ef934922cf6707252a01d41088679891df4bcc64f5169e
3
+ metadata.gz: 46359b95123b84264bb61b3ce21c2ecc9375bb5cc45c0df5d36a398bc6762ae8
4
+ data.tar.gz: 7c322211d19b5412a143ea5dd2d88fa93b3c018b73aefcca7f41ef5e8d74c03f
5
5
  SHA512:
6
- metadata.gz: 9129b9f8b938cc9ce5fb81f9036845e50a9c0c3d194d2918c3e663cc8922096fc05bc3d404147797c813e475949256d735ff5e21cc429449fcd59efd9eb02dc2
7
- data.tar.gz: 0f98714662bc5c53e5224ba80b05234272b05ea791d1e2e01548a734b1161040a64029c2392e17a776cb467382622bc6a104883920ccf1fb108d4dbd2fe07124
6
+ metadata.gz: 750cc3e95af36b4d07521b59b6c60547fc6274421861e38cd4afcb7f44df7e3057e2b51b370a1dbcbcb8dcf5012a16f70ad1084ac306531bfd9280d71a186bce
7
+ data.tar.gz: 1d83fc2833cc6a6f10f9e02d1a8b9852b3786f42cb3d1cf5a64b06489858af895b92b68be2ec35139b23d56773eddcfc81cd79f2cb1cfe9c0edaa5450544ebbe
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ChewyQueries
1
+ ### ChewyQueries
2
2
 
3
3
  This gem help you to fire the Elastic query directly.This gem is completely depending on chewy gem (Elastic search) you will get more info in (https://github.com/toptal/chewy)
4
4
 
@@ -23,15 +23,22 @@ This gem requires Ruby 2.4+, Rails 5.0+ and Chewy 5.2.0
23
23
 
24
24
  ### Search query requires the following
25
25
 
26
- ## Fields types
26
+ #def ChewyQueries.search(class_name, type, condition, value, field)
27
+ ------
28
+ ------
29
+ ------
30
+ #end
27
31
 
32
+ ## class_name should be your index class name
33
+
34
+ ## type is Fields types i.e:-
28
35
  1)text
29
36
  2)number
30
37
  3)date
31
38
 
32
- ### Operators required for each fields
39
+ ### Condition required for each fields
33
40
 
34
- ## 1)text field
41
+ # 1)text field
35
42
  1)equal
36
43
  2)not equal
37
44
  3)contains
@@ -42,7 +49,7 @@ This gem requires Ruby 2.4+, Rails 5.0+ and Chewy 5.2.0
42
49
  8)does not end with
43
50
  9)matches exactly
44
51
 
45
- ## 2)number field
52
+ # 2)number field
46
53
  1)Is equal to
47
54
  2)Is not equal to
48
55
  3)Is greater than
@@ -51,7 +58,7 @@ This gem requires Ruby 2.4+, Rails 5.0+ and Chewy 5.2.0
51
58
  6)Is not provided
52
59
  7)Is between
53
60
 
54
- ## 3)date field
61
+ # 3)date field
55
62
  1)Is before
56
63
  2)Is after
57
64
  3)Is on or before
@@ -62,3 +69,5 @@ This gem requires Ruby 2.4+, Rails 5.0+ and Chewy 5.2.0
62
69
  8)Is not provided
63
70
  9)Is between
64
71
 
72
+ ## value should be your search value
73
+ ## field should be your search filed
data/lib/chewy_queries.rb CHANGED
@@ -5,15 +5,15 @@ class ChewyQueries
5
5
  if condition == "equal"
6
6
  class_name.query(match_phrase: {"#{field}": value})
7
7
  elsif condition == "not equal"
8
- class_name.query.not(match: {"#{field}": value}).and(ContactIndex.query.not(match: {"#{field}": "null"}))
8
+ class_name.query.not(match: {"#{field}": value}).and(class_name.query.not(match: {"#{field}": "null"}))
9
9
  elsif condition == "contains"
10
- class_name.query(regexp: {"#{field}": ".*#{value.downcase}.*"}).or(ContactIndex.query(match_phrase: {"#{field}": value}))
10
+ class_name.query(regexp: {"#{field}": ".*#{value.downcase}.*"}).or(class_name.query(match_phrase: {"#{field}": value}))
11
11
  elsif condition == "does not contain"
12
- class_name.query.not(regexp: {"#{field}": ".*#{value.downcase}.*"}).and(ContactIndex.query.not(match: {"#{field}": "null"}))
12
+ class_name.query.not(regexp: {"#{field}": ".*#{value.downcase}.*"}).and(class_name.query.not(match: {"#{field}": "null"}))
13
13
  elsif condition == "starts with"
14
14
  class_name.query(regexp: {"#{field}": "#{value.downcase}.*"})
15
15
  elsif condition == "does not start with"
16
- class_name.query.not(regexp: {"#{field}": "#{value.downcase}.*"}).and(ContactIndex.query.not(match: {"#{field}": "null"}))
16
+ class_name.query.not(regexp: {"#{field}": "#{value.downcase}.*"}).and(class_name.query.not(match: {"#{field}": "null"}))
17
17
  elsif condition == "ends with"
18
18
  class_name.query(regexp: {"#{field}": ".*#{value.downcase}"})
19
19
  elsif condition == "does not end with"
@@ -29,7 +29,7 @@ class ChewyQueries
29
29
  elsif condition == "Is greater than"
30
30
  class_name.query(range: {"#{field}": {gt: value}})
31
31
  elsif condition == "Is less than"
32
- class_name.query(range: {"#{field}": {lt: value}}).and(ContactIndex.query.not(match: {"#{field}": 0}))
32
+ class_name.query(range: {"#{field}": {lt: value}}).and(class_name.query.not(match: {"#{field}": 0}))
33
33
  elsif condition == "Is provided"
34
34
  class_name.query.not(match: {"#{field}": 0})
35
35
  elsif condition == "Is not provided"
@@ -1,3 +1,3 @@
1
1
  module ChewyQueries
2
- VERSION = '0.0.0'
2
+ VERSION = '0.0.1'
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.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rakesh