chewy_queries 0.0.2 → 0.0.3

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: add0b2391e69e66947d7323c8f296e53275d4b5d6a179ad2fbc800115908493f
4
- data.tar.gz: ae14f4c97ab71d2ea790992dc8b9396271f9b0278ee236456b85df4f09f306de
3
+ metadata.gz: 8a44148fe1c365c4907380ecba044b436611e67b62ffc55a86275a52097bf1f8
4
+ data.tar.gz: 3f78b696b02be625c741a6a695a2837d691bdbd3aac9f9f584c902fa9db680d8
5
5
  SHA512:
6
- metadata.gz: 548ed26e5bc14e219371e15d74e405346965bb486f4604b49ef2da9af98cd1a7eb0f5fc0952da1c982efec5367be657cceeb24a8c876f4248e52b5af099395d2
7
- data.tar.gz: c0ab9fa4fd9f8933c8731be3386af093423d97a9c8739d19ea3cc4a99d1b2f6dd3373cc2eec95d7902dd40200d15426ad7f29761f4bd146094aeb7bcc5cc79cb
6
+ metadata.gz: b07b58608223b4aec4bf6af95202308baaf1539c68fc294a915e64b9c565b57fbccee639a8f3e14bd9394bf710faa0e7e2745269c050a35e853d6cd5a3f150bf
7
+ data.tar.gz: 3f02574c67a4e79eaaaac29c3b18d36b3cd00318a36cf1224fe05487aaac92d3820e514e5c64b55ee6b677aee29bafaca09fae899e91375a4da113c4684f899b
data/README.md CHANGED
@@ -1,44 +1,52 @@
1
- ### ChewyQueries
1
+ # ChewyQueries
2
2
 
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)
3
+ This gem is completely depending on Chewy gem (Elastic search) you will get more info in [Chewy-gem](https://github.com/toptal/chewy).
4
+ First develop the index by using Chewy gem, then you can this gem for firing the queries to get result.
4
5
 
5
6
  ## Getting started
6
7
 
7
8
  ### Requirements
9
+
10
+ This gem requires Ruby 2.4+, Rails 5.0+ and Chewy 5.2.0
11
+
12
+ ### Installation
13
+
8
14
  Add the gem to your `Gemfile`:
9
15
 
16
+ ```ruby
10
17
  gem 'chewy_queries'
18
+ ```
11
19
 
12
20
  and run:
13
21
 
22
+ ```
14
23
  bundle install
15
-
24
+ ```
16
25
  or
17
26
 
27
+ ```
18
28
  gem install chewy_queries
19
-
20
- require 'chewy_queries'
21
-
22
- This gem requires Ruby 2.4+, Rails 5.0+ and Chewy 5.2.0
29
+ ```
23
30
 
24
31
  ## Search query requires the following
25
32
 
26
- ## def ChewyQueries.search(class_name, type, condition, value, field)
27
- # some elastic queries
28
- ## end
33
+ ```ruby
34
+ def ChewyQueries.search(class_name, type, condition, value, field)
35
+ # some elastic queries
36
+ end
37
+ ```
29
38
 
30
- Above method includes all possible query to get the search result.
31
-
32
- ## class_name should be your index class name
39
+ Above method includes all possible elastic queries to get the search result.
33
40
 
41
+ ## method explaination
34
42
  ## type is Fields types i.e:-
35
43
  1)text
36
44
  2)number
37
45
  3)date
38
46
 
39
- ### Condition required for each fields
47
+ ## Condition required for each fields
40
48
 
41
- # 1)text field
49
+ ### 1)text field
42
50
  1)equal
43
51
  2)not equal
44
52
  3)contains
@@ -49,7 +57,7 @@ Above method includes all possible query to get the search result.
49
57
  8)does not end with
50
58
  9)matches exactly
51
59
 
52
- # 2)number field
60
+ ### 2)number field
53
61
  1)Is equal to
54
62
  2)Is not equal to
55
63
  3)Is greater than
@@ -58,7 +66,7 @@ Above method includes all possible query to get the search result.
58
66
  6)Is not provided
59
67
  7)Is between
60
68
 
61
- # 3)date field
69
+ ### 3)date field
62
70
  1)Is before
63
71
  2)Is after
64
72
  3)Is on or before
@@ -70,4 +78,16 @@ Above method includes all possible query to get the search result.
70
78
  9)Is between
71
79
 
72
80
  ## value should be your search value
73
- ## field should be your search filed
81
+ ## field should be your search filed
82
+
83
+ ## Note:This gem will give maximum 10 result if you want more than 10 you can use limit(limit(1000)) after calling methods.
84
+
85
+
86
+ ## Example
87
+
88
+ ```ruby
89
+ ChewyQueries.search(ContactIndex, "number", "Is equal to", 23, "age").limit(Contact.count)
90
+ #limit is get more than 10 result
91
+
92
+ ```
93
+
data/lib/chewy_queries.rb CHANGED
@@ -66,19 +66,19 @@ class ChewyQueries
66
66
  end
67
67
 
68
68
  def self.exact_match_search(class_name, field, value)
69
- class_name.query(match_phrase: {"#{field}": value}).to_a
69
+ class_name.query(match_phrase: {"#{field}": value})
70
70
  end
71
71
 
72
72
  def self.partial_search(class_name, field, value)
73
- class_name.query(regexp: {"#{field}": ".*#{value.downcase}.*"}).to_a
73
+ class_name.query(regexp: {"#{field}": ".*#{value.downcase}.*"})
74
74
  end
75
75
 
76
76
  def self.multiple_field_search(class_name, multiple_field_array, value)
77
77
  exact_search = []
78
78
  partial_search = []
79
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
80
+ exact_search << class_name.query(match_phrase: {"#{field}": value})
81
+ partial_search << class_name.query(regexp: {"#{field}": ".*#{value.downcase}.*"})
82
82
  end
83
83
  search = exact_search + partial_search
84
84
  return search.uniq
@@ -1,3 +1,3 @@
1
1
  module ChewyQueries
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rakesh