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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 335008cad4298d74c3a008b6dc3d9e6ab0f52588
4
- data.tar.gz: b1dae029204a1a1db586a9018f8e2d7c314d96f2
3
+ metadata.gz: 9a48727f1ce5747eb4e17b40c6f1c127ab6e9856
4
+ data.tar.gz: 0184aedf458884c6096147a4d567da364d7139f0
5
5
  SHA512:
6
- metadata.gz: 34f19cb0137d62bf6d5ded203ae279f3d885aa42b1e3536865aff772e84f70a925f23d2add0a4ecf3125747aa25b870a91eab97c2aa9c8a7b16cc8d300023d7e
7
- data.tar.gz: e4d1196c9b3473289cd69c42ee586739f0fd317873f2492e7e8aaec59721a10cf08dfac551b6f2045d180d5b31b892856c46a071cab1c3aa2d22bab63e79290c
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.8.7, 1.9.3, 2.0.0, 2.1.0, and 2.1.2
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]}"
@@ -1,3 +1,3 @@
1
1
  module Rawscsi
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -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.1
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-19 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler