rawscsi 1.0.1 → 1.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 +4 -4
- data/README.md +19 -6
- data/lib/rawscsi/query/compound.rb +7 -1
- data/lib/rawscsi/version.rb +1 -1
- data/spec/lib/rawscsi/query/compound_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a48727f1ce5747eb4e17b40c6f1c127ab6e9856
|
4
|
+
data.tar.gz: 0184aedf458884c6096147a4d567da364d7139f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1984ddc35a40d5e656a033aebaa8196f149f7273a0016b60be0a2f2476d65a1949063ea27f427ef438f5976930f0885353827326667bca7343e92a806e65e15
|
7
|
+
data.tar.gz: fd9f43df1cf9dac1d3a270ae159f94b7a76e84659e4b230f4d2473a030f0752e5149655483a0dbb807698333bb97d5e80bbf1e6c2f65db064c44ecdc26c9cb73
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ search_object.search(q: {
|
|
27
27
|
}
|
28
28
|
}]
|
29
29
|
},
|
30
|
-
date: {release_date: "[1970-01-01,}"},
|
30
|
+
date: {release_date: "['1970-01-01',}"},
|
31
31
|
sort: "rating desc",
|
32
32
|
limit: 3
|
33
33
|
)
|
@@ -40,7 +40,9 @@ In theory, if the query is allowed on Cloudsearch, this gem can construct it.
|
|
40
40
|
|
41
41
|
4) Has some nice Active Record integration features.
|
42
42
|
|
43
|
-
5) Supports Ruby 1.
|
43
|
+
5) Supports Ruby 1.9.3, 2.0.0, 2.1.0, and 2.1.2
|
44
|
+
|
45
|
+
6) Supports Pagination
|
44
46
|
|
45
47
|
Here's the official aws cloud search documentation: http://docs.aws.amazon.com/cloudsearch/latest/developerguide/what-is-cloudsearch.html
|
46
48
|
|
@@ -96,9 +98,10 @@ book_indexer = Rawscsi::Index.new('Book')
|
|
96
98
|
# since Book is not an active record object, we upload hashes instead
|
97
99
|
# Note the id key in the hash will be used as the cloud search record id.
|
98
100
|
book_indexer.upload([
|
99
|
-
{id: 1234, title: "Surely you're Joking, Mr. Feynman", author: "Richard Feynman"},
|
100
|
-
{id: 5546, title: "Zen and the Art of Motorcycle Maintanence", author: "Robert Pirsig"}
|
101
|
+
{id: 1234, title: "Surely you're Joking, Mr. Feynman", author: "Richard Feynman", publish_date: "1985-01-01T00:00:00Z"},
|
102
|
+
{id: 5546, title: "Zen and the Art of Motorcycle Maintanence", author: "Robert Pirsig", publish_date: "1974-04-01T00:00:00Z"}
|
101
103
|
])
|
104
|
+
# Also note the date format
|
102
105
|
```
|
103
106
|
|
104
107
|
### Deleting indices
|
@@ -182,13 +185,13 @@ search_songs.search(q: {
|
|
182
185
|
{ title: "Street"}
|
183
186
|
]
|
184
187
|
},
|
185
|
-
date: { release_date: "[1995-01-01,}"}
|
188
|
+
date: { release_date: "['1995-01-01',}"}
|
186
189
|
limit: 5,
|
187
190
|
sort: "rating desc"
|
188
191
|
)
|
189
192
|
# Conjunction of two constraints and date constraint (Top 5 Hip Hop songs with Street in title released after 1995)
|
190
193
|
# Note date syntax is working in conjunction (and) with the frist two constraints. This is always the case.
|
191
|
-
# Also note syntax for searching date ranges: "[1995-01-01,}" is all dates after Jan 1 1995 while "{,1995-01-01]" is all dates before.
|
194
|
+
# Also note syntax for searching date ranges: "['1995-01-01',}" is all dates after Jan 1 1995 while "{,'1995-01-01']" is all dates before.
|
192
195
|
# Note we're limiting only 5 results and sorting by rating in descending order.
|
193
196
|
=> [{song_id: 54642, title: "Street Dreams", artist: "Nas"},
|
194
197
|
{song_id: 98786, title: "Street Struck", artist: "Big L"},
|
@@ -253,6 +256,16 @@ search_songs.search(q: {and: [ {artist: "Cold Play"} ],
|
|
253
256
|
|
254
257
|
```
|
255
258
|
|
259
|
+
### Pagination
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
# paginate with the `start` and `limit` params
|
263
|
+
search_songs.search(q: {and: [{artist: "Beatles"}]},
|
264
|
+
start: 25,
|
265
|
+
limit: 5)
|
266
|
+
```
|
267
|
+
|
268
|
+
|
256
269
|
## Contributing
|
257
270
|
|
258
271
|
1. Fork it
|
@@ -11,6 +11,7 @@ module Rawscsi
|
|
11
11
|
query,
|
12
12
|
date,
|
13
13
|
sort,
|
14
|
+
start,
|
14
15
|
limit,
|
15
16
|
fields,
|
16
17
|
"q.parser=structured"
|
@@ -42,7 +43,12 @@ module Rawscsi
|
|
42
43
|
return nil unless query_hash[:sort]
|
43
44
|
encode("sort=#{query_hash[:sort]}")
|
44
45
|
end
|
45
|
-
|
46
|
+
|
47
|
+
def start
|
48
|
+
return nil unless query_hash[:start]
|
49
|
+
"start=#{query_hash[:start]}"
|
50
|
+
end
|
51
|
+
|
46
52
|
def limit
|
47
53
|
return nil unless query_hash[:limit]
|
48
54
|
"size=#{query_hash[:limit]}"
|
data/lib/rawscsi/version.rb
CHANGED
@@ -76,5 +76,15 @@ describe Rawscsi::Query::Compound do
|
|
76
76
|
|
77
77
|
expect(str).to eq("q=(and%20title:%27star%27(not%20title:%27wars%27))&q.parser=structured")
|
78
78
|
end
|
79
|
+
|
80
|
+
it "constructs a query with pagination" do
|
81
|
+
arg = {
|
82
|
+
:q => {:and => [{:title => "star wars"}]},
|
83
|
+
:start => 2,
|
84
|
+
:limit => 3
|
85
|
+
}
|
86
|
+
str = Rawscsi::Query::Compound.new(arg).build
|
87
|
+
expect(str).to eq("q=(and%20title:%27star%20wars%27)&start=2&size=3&q.parser=structured")
|
88
|
+
end
|
79
89
|
end
|
80
90
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rawscsi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|