clusterpoint 0.2.2 → 0.2.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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +31 -21
- data/lib/cluster_point/cluster_point_adapter.rb +6 -5
- data/lib/cluster_point/configuration.rb +3 -0
- data/lib/cluster_point/finder_methods.rb +8 -3
- data/lib/cluster_point/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13d4d1ff1b7c87171be7c76a357d8bf80a6a8f1f
|
4
|
+
data.tar.gz: ca9701eaf8731a1625582902340662db4aa4b845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e77a0bcdc9c43e6e6a15aa0480dae90d2e915c3f867895adedc2b926f0af9d07c47edc12d85753afd270ed54534ae7198ade2a07da63f27fc751d940fd61c8f7
|
7
|
+
data.tar.gz: 739ff0c7de2f454b146fe9df85ae37d459b7b0c53e180415d7296637a205c59d2c97ebab0b93f93c8d121d68a1421cc2a78d23a71c44e35ec2256069aece8555
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Overview
|
2
|
+
|
3
|
+
## 0.2.3
|
4
|
+
|
5
|
+
### New Features
|
6
|
+
|
7
|
+
* Exposed where method
|
8
|
+
* Added Clusterpoint order support (default order by ID ascending)
|
9
|
+
- `Item.where(query_hash, order_hash, record_count, start_offset)`
|
10
|
+
- `Item.where({code: "A*"}, {string: {code: :ascending}})`
|
11
|
+
- More about query syntax:
|
12
|
+
- http://docs.clusterpoint.com/wiki/Search_query_syntax
|
13
|
+
- http://docs.clusterpoint.com/wiki/Alphabetic_Ordering
|
14
|
+
* Moved HTTP request debug setting to configuration file
|
15
|
+
debug_output: $stdout
|
data/README.md
CHANGED
@@ -28,38 +28,48 @@ Add railtie require to your application.rb file:
|
|
28
28
|
### Database connection
|
29
29
|
Add cluster_point.yml file under config directory. Following format;
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
```
|
32
|
+
development:
|
33
|
+
url: https://api.clusterpoint.com
|
34
|
+
account_id: [Clusterpoint cloud api account ID]
|
35
|
+
database: [Database to use]
|
36
|
+
username: [Clusterpoint cloud username]
|
37
|
+
password: [Clusterpoint cloud password]
|
38
|
+
[debug_output: $stdout]
|
39
|
+
```
|
37
40
|
|
38
41
|
### Framework usage
|
39
42
|
To make model as Clusterpoint document innerhit it from `ClusterPoint::Document`
|
40
43
|
|
41
44
|
To define subdocuments you can use one of two options - `contains` (if contains single subdocument) or `contains_many` (if contains more than one subdocument):
|
42
45
|
|
43
|
-
|
44
|
-
|
46
|
+
```ruby
|
47
|
+
contains_many :translations
|
48
|
+
contains :author
|
49
|
+
```
|
45
50
|
|
46
51
|
Example:
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
```ruby
|
54
|
+
class Item < ClusterPoint::Document
|
55
|
+
contains_many :translations
|
56
|
+
contains_many :locations
|
57
|
+
contains :author
|
58
|
+
end
|
59
|
+
```
|
53
60
|
|
54
61
|
### Basic operations
|
55
|
-
* Item.all - retrieve all documents with type Item (models are divided with document attribute `type`)
|
56
|
-
* Item.find(id) - retrieve document with ID = id
|
57
|
-
* Item.new_from_hash(item_params.to_h) - create new document from hash
|
58
|
-
*
|
59
|
-
*
|
60
|
-
*
|
61
|
-
* .where(
|
62
|
-
|
62
|
+
* `Item.all` - retrieve all documents with type Item (models are divided with document attribute `type`)
|
63
|
+
* `Item.find(id)` - retrieve document with ID = id
|
64
|
+
* `Item.new_from_hash(item_params.to_h)` - create new document from hash
|
65
|
+
* `@item.save` - save document
|
66
|
+
* `@item.update(item_params.to_h)` - update document and save changes
|
67
|
+
* `@item.destroy `- delete document
|
68
|
+
* `Item.where(query_hash, order_hash, record_count, start_offset)` - custom query.
|
69
|
+
* `Item.where({code: "A*"}, {string: {code: :ascending}})`
|
70
|
+
- More about query syntax:
|
71
|
+
- http://docs.clusterpoint.com/wiki/Search_query_syntax
|
72
|
+
- http://docs.clusterpoint.com/wiki/Alphabetic_Ordering
|
63
73
|
|
64
74
|
## Development
|
65
75
|
|
@@ -5,7 +5,6 @@ module ClusterPoint
|
|
5
5
|
|
6
6
|
class ClusterPointAdapter
|
7
7
|
include HTTParty
|
8
|
-
debug_output $stdout
|
9
8
|
include ClusterPoint::Configuration
|
10
9
|
|
11
10
|
def initialize
|
@@ -62,10 +61,12 @@ module ClusterPoint
|
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
65
|
-
def where(
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
def where(conditions={}, ordering={string: {id: :ascending}}, docs=20, offset=0)
|
65
|
+
query_xml = conditions.to_xml(skip_instruct: true, skip_types: true, indent: 1)
|
66
|
+
ordering_xml = ordering.to_xml(skip_instruct: true, skip_types: true, indent: 1)
|
67
|
+
options = { body: [{ query: query_xml.lines.to_a[1..-2].join,
|
68
|
+
ordering: ordering_xml.lines.to_a[1..-2].join,
|
69
|
+
docs: docs,
|
69
70
|
offset: offset
|
70
71
|
}].to_json,
|
71
72
|
basic_auth: @auth,
|
@@ -2,8 +2,13 @@ require 'json'
|
|
2
2
|
module ClusterPoint
|
3
3
|
module FinderMethods
|
4
4
|
|
5
|
-
def all()
|
6
|
-
respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase})))
|
5
|
+
def all(ordering={string: {id: :ascending}})
|
6
|
+
respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase}, ordering)))
|
7
|
+
end
|
8
|
+
|
9
|
+
def where(conditions={}, ordering={string: {id: :ascending}}, docs=20, offset=0)
|
10
|
+
conditions.merge!({type: self.to_s.upcase})
|
11
|
+
respToArray(JSON.parse(get_cp.where(conditions, ordering, docs, offset)))
|
7
12
|
end
|
8
13
|
|
9
14
|
def find(*ids)
|
@@ -36,7 +41,7 @@ module ClusterPoint
|
|
36
41
|
protected
|
37
42
|
|
38
43
|
def get_some(ids)
|
39
|
-
items = respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase, id: "{" + ids.join(" ") + "}"}, ids.size
|
44
|
+
items = respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase, id: "{" + ids.join(" ") + "}"}, docs: ids.size)))
|
40
45
|
if items.size != ids.size
|
41
46
|
raise RecordNotFound
|
42
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clusterpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janis Baiza
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- .gitignore
|
148
148
|
- .rspec
|
149
149
|
- .travis.yml
|
150
|
+
- CHANGELOG.md
|
150
151
|
- Gemfile
|
151
152
|
- LICENSE
|
152
153
|
- README.md
|