oss_rb 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 815f0b43a11334680f8f50b8fab3037fbf2df2c7
4
- data.tar.gz: 1714fe080a3ad9f234e6f0a5a296b69c35067920
3
+ metadata.gz: 3044cabe261b39f26814fc907b63f7291a3e80ec
4
+ data.tar.gz: 9719d4a84617265be04efcc6debceec8be489291
5
5
  SHA512:
6
- metadata.gz: 6fc52574172fff5cdff96c70bdc0d1616365cc12515971d91a7b92f18ce78a99ce6d50df6986f452510c6757a3a8f323e5bf6a5fe220ed180205603012e4b0a6
7
- data.tar.gz: 7ca333c4ac47084fbca8145f5966e9fdfe88ea59b596544b83333df56657a3d3e69794759a1a6b836e487bfb468346d26bdb50c99201a35720c262c06f98cebd
6
+ metadata.gz: cf175a661bbc9f2279d4e8d36ab39561c414327861e9bdb0f1f7f222899cfee020ba7df8a36c8b0b340a03c78b026ddc4675683c7c5c5003aa3665397f2a27b6
7
+ data.tar.gz: 1f02e6b845dfec7719e14bc4b655a0ec5c3ce4ec2a907e4796d1760f6f8a807c55f94987e99d46af774568b461994b2b6e1c38fe25c971eb17dcf7d66d2c6357
@@ -6,6 +6,7 @@ module Oss
6
6
  attr_accessor :documents, :name
7
7
  def initialize(name, host = 'http://localhost:8080', login = nil, key = nil)
8
8
  @name = name
9
+ @urlname = URI.encode(name)
9
10
  @documents = Array.new
10
11
  @host = host
11
12
  @credentials = {:login=>login,:key=>key}
@@ -20,92 +21,92 @@ module Oss
20
21
  # Create a new index with the given template name
21
22
  # http://github.com/jaeksoft/opensearchserver/wiki/Index-create
22
23
  def create(template = 'WEB_CRAWLER')
23
- api_post "services/rest/index/#{@name}/template/#{template}"
24
+ api_post "services/rest/index/#{@urlname}/template/#{template}"
24
25
  end
25
26
 
26
27
  # Delete the index
27
28
  # http://github.com/jaeksoft/opensearchserver/wiki/Index-delete
28
29
  def delete!
29
- api_delete "services/rest/index/#{@name}"
30
+ api_delete "services/rest/index/#{@urlname}"
30
31
  end
31
32
 
32
33
  # Create or update the field defined by the given hash
33
34
  # http://github.com/jaeksoft/opensearchserver/wiki/Field-create-update
34
35
  def set_field(field_params)
35
- api_put_json "services/rest/index/#{@name}/field/#{URI.encode(field_params['name'])}", field_params
36
+ api_put_json "services/rest/index/#{@urlname}/field/#{URI.encode(field_params['name'])}", field_params
36
37
  end
37
38
 
38
39
  # Set the default field and the unique field
39
40
  # http://github.com/jaeksoft/opensearchserver/wiki/Field-set-default-unique
40
41
  def set_field_default_unique(default, unique)
41
42
  params = { 'unique' => unique, 'default' => default }
42
- api_post "services/rest/index/#{@name}/field", '', params
43
+ api_post "services/rest/index/#{@urlname}/field", '', params
43
44
  end
44
45
 
45
46
  # Delete the field matching the give name
46
47
  # http://github.com/jaeksoft/opensearchserver/wiki/Field-delete
47
48
  def delete_field(field_name = nil)
48
- api_delete "services/rest/index/#{@name}/field/#{field_name}"
49
+ api_delete "services/rest/index/#{@urlname}/field/#{URI.encode(field_name)}"
49
50
  end
50
51
 
51
52
  # Delete the document matching the given field and values
52
53
  # http://github.com/jaeksoft/opensearchserver/wiki/Document-delete
53
54
  def delete_document_by_value(field_name, *values)
54
- api_delete "services/rest/index/#{@name}/document/#{field_name}/#{values.join('/')}"
55
+ api_delete "services/rest/index/#{@urlname}/document/#{URI.encode(field_name)}/#{values.join('/')}"
55
56
  end
56
57
 
57
58
  # Delete the document matching the given query
58
59
  def delete_document_by_query(query)
59
60
  params = { 'query' => query }
60
- api_delete "services/rest/index/#{@name}/document", params
61
+ api_delete "services/rest/index/#{@urlname}/document", params
61
62
  end
62
63
 
63
64
  # Put document in the index
64
65
  # http://github.com/jaeksoft/opensearchserver/wiki/Document-put-JSON
65
66
  def index!
66
- api_put_json "services/rest/index/#{@name}/document", @documents
67
+ api_put_json "services/rest/index/#{@urlname}/document", @documents
67
68
  @documents = []
68
69
  end
69
70
 
70
71
  # Execute a search (using pattern)
71
72
  def search_pattern( body = nil)
72
- JSON.parse(api_post_json("services/rest/index/#{@name}/search/pattern", body))
73
+ JSON.parse(api_post_json("services/rest/index/#{@urlname}/search/pattern", body))
73
74
  end
74
75
 
75
76
  # Execute a search (using field)
76
77
  # http://github.com/jaeksoft/opensearchserver/wiki/Search-field
77
78
  def search_field(body = nil)
78
- JSON.parse(api_post_json("services/rest/index/#{@name}/search/field", body))
79
+ JSON.parse(api_post_json("services/rest/index/#{@urlname}/search/field", body))
79
80
  end
80
81
 
81
82
  # Execute a search based on an existing template
82
83
  # http://github.com/jaeksoft/opensearchserver/wiki/Search-pattern
83
84
  def search_template_pattern(template, body = nil)
84
- JSON.parse(api_post_json("services/rest/index/#{@name}/search/pattern/#{template}", body))
85
+ JSON.parse(api_post_json("services/rest/index/#{@urlname}/search/pattern/#{template}", body))
85
86
  end
86
87
 
87
88
  # Execute a search based on an existing template
88
89
  # http://github.com/jaeksoft/opensearchserver/wiki/Search-template-field
89
90
  def search_template_field(template, body = nil)
90
- JSON.parse(api_post_json("services/rest/index/#{@name}/search/field/#{template}", body))
91
+ JSON.parse(api_post_json("services/rest/index/#{@urlname}/search/field/#{template}", body))
91
92
  end
92
93
 
93
94
  # Create/update a search template (pattern search)
94
95
  # http://github.com/jaeksoft/opensearchserver/wiki/Search-template-pattern-set
95
96
  def search_store_template_pattern(template, body = nil)
96
- api_put_json "services/rest/index/#{@name}/search/pattern/#{template}", body
97
+ api_put_json "services/rest/index/#{@urlname}/search/pattern/#{template}", body
97
98
  end
98
99
 
99
100
  # Create/update a search template (field search)
100
101
  # http://github.com/jaeksoft/opensearchserver/wiki/Search-template-field-set
101
102
  def search_store_template_field(template, body = nil)
102
- api_put_json"services/rest/index/#{@name}/search/field/#{template}", body
103
+ api_put_json"services/rest/index/#{@urlname}/search/field/#{template}", body
103
104
  end
104
105
 
105
106
  # Delete a search template matching the given name
106
107
  # http://github.com/jaeksoft/opensearchserver/wiki/Search-template-delete
107
108
  def search_template_delete(template)
108
- api_delete "services/rest/index/#{@name}/search/template/#{template}"
109
+ api_delete "services/rest/index/#{@urlname}/search/template/#{template}"
109
110
  end
110
111
 
111
112
  private
@@ -1,3 +1,3 @@
1
1
  module Oss
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -139,12 +139,12 @@ describe Oss::Index do
139
139
  it 'index docs, delete document by value' do
140
140
  @index.delete_document_by_value('id', 1, 2, 3)
141
141
  end
142
+ end
142
143
 
143
- describe '#delete document by query' do
144
- it 'index docs, delete document by query' do
145
- @index.delete_document_by_query('user:john4')
146
- @index.delete_document_by_query('user:john5')
147
- end
144
+ describe '#delete document by query' do
145
+ it 'index docs, delete document by query' do
146
+ @index.delete_document_by_query('user:john4')
147
+ @index.delete_document_by_query('user:john5')
148
148
  end
149
149
  end
150
150
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oss_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ori Pekelman
@@ -77,7 +77,6 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - .gitignore
79
79
  - Gemfile
80
- - Gemfile.lock
81
80
  - LICENSE.txt
82
81
  - README.md
83
82
  - Rakefile
@@ -1,97 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- oss_rb (0.1.2)
5
- activesupport
6
- rest-client
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activesupport (4.0.0)
12
- i18n (~> 0.6, >= 0.6.4)
13
- minitest (~> 4.2)
14
- multi_json (~> 1.3)
15
- thread_safe (~> 0.1)
16
- tzinfo (~> 0.3.37)
17
- atomic (1.1.14)
18
- coderay (1.0.9)
19
- diff-lcs (1.2.4)
20
- ffi (1.3.1)
21
- formatador (0.2.4)
22
- guard (1.8.1)
23
- formatador (>= 0.2.4)
24
- listen (>= 1.0.0)
25
- lumberjack (>= 1.0.2)
26
- pry (>= 0.9.10)
27
- thor (>= 0.14.6)
28
- guard-bundler (1.0.0)
29
- bundler (~> 1.0)
30
- guard (~> 1.1)
31
- guard-rack (1.3.1)
32
- ffi (~> 1.3.1)
33
- guard (~> 1.1)
34
- libnotify (~> 0.1.3)
35
- rb-inotify (>= 0.5.1)
36
- spoon (~> 0.0.1)
37
- i18n (0.6.5)
38
- libnotify (0.1.4)
39
- ffi (>= 0.6.2)
40
- listen (1.2.2)
41
- rb-fsevent (>= 0.9.3)
42
- rb-inotify (>= 0.9)
43
- rb-kqueue (>= 0.2)
44
- lumberjack (1.0.4)
45
- method_source (0.8.1)
46
- mime-types (1.25)
47
- minitest (4.7.5)
48
- multi_json (1.8.1)
49
- net-http-spy (0.2.1)
50
- pry (0.9.12.2)
51
- coderay (~> 1.0.5)
52
- method_source (~> 0.8)
53
- slop (~> 3.4)
54
- rack (1.5.2)
55
- rack-test (0.6.2)
56
- rack (>= 1.0)
57
- rake (10.1.0)
58
- rb-fsevent (0.9.3)
59
- rb-inotify (0.9.0)
60
- ffi (>= 0.5.0)
61
- rb-kqueue (0.2.0)
62
- ffi (>= 0.5.0)
63
- rest-client (1.6.7)
64
- mime-types (>= 1.16)
65
- rspec (2.14.1)
66
- rspec-core (~> 2.14.0)
67
- rspec-expectations (~> 2.14.0)
68
- rspec-mocks (~> 2.14.0)
69
- rspec-core (2.14.2)
70
- rspec-expectations (2.14.0)
71
- diff-lcs (>= 1.1.3, < 2.0)
72
- rspec-mocks (2.14.1)
73
- slop (3.4.5)
74
- spoon (0.0.4)
75
- ffi
76
- thor (0.18.1)
77
- thread_safe (0.1.3)
78
- atomic
79
- tzinfo (0.3.37)
80
-
81
- PLATFORMS
82
- ruby
83
-
84
- DEPENDENCIES
85
- bundler (~> 1.3)
86
- guard
87
- guard-bundler
88
- guard-rack
89
- net-http-spy
90
- oss_rb!
91
- pry
92
- rack-test
93
- rake
94
- rspec
95
- rspec-core
96
- rspec-expectations
97
- rspec-mocks