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 +4 -4
- data/README.md +15 -6
- data/lib/chewy_queries.rb +5 -5
- data/lib/chewy_queries/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46359b95123b84264bb61b3ce21c2ecc9375bb5cc45c0df5d36a398bc6762ae8
|
|
4
|
+
data.tar.gz: 7c322211d19b5412a143ea5dd2d88fa93b3c018b73aefcca7f41ef5e8d74c03f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 750cc3e95af36b4d07521b59b6c60547fc6274421861e38cd4afcb7f44df7e3057e2b51b370a1dbcbcb8dcf5012a16f70ad1084ac306531bfd9280d71a186bce
|
|
7
|
+
data.tar.gz: 1d83fc2833cc6a6f10f9e02d1a8b9852b3786f42cb3d1cf5a64b06489858af895b92b68be2ec35139b23d56773eddcfc81cd79f2cb1cfe9c0edaa5450544ebbe
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
39
|
+
### Condition required for each fields
|
|
33
40
|
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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"
|