elasticsearch-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ module ElasticSearch
13
13
  end
14
14
  alias :[] :get_type
15
15
 
16
- def search(body, parameters)
16
+ def search(body, parameters = {})
17
17
  request = build_request(method: :get, action: :search, parameters: parameters, body: body || {})
18
18
  response = execute(request)
19
19
  ElasticSearch::Search::Results.new(response)
@@ -20,7 +20,7 @@ module ElasticSearch
20
20
  end
21
21
 
22
22
  def body
23
- @encoded_body ||= @body.to_json
23
+ @encoded_body ||= @body.is_a?(String) ? @body : @body.to_json
24
24
  end
25
25
 
26
26
  def path
@@ -1,3 +1,3 @@
1
1
  module ElasticSearch
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -48,6 +48,17 @@ describe ElasticSearch::Client do
48
48
  client.has_index?(TEST_INDEX).must_equal true
49
49
  end
50
50
  end
51
+
52
+ describe :bulk do
53
+ it "should bulk insert documents" do
54
+ client.create_index(TEST_INDEX).refresh
55
+ objects = (1..2).collect do |i|
56
+ ["{ \"index\" : { \"_index\" : \"#{TEST_INDEX}\", \"_type\" : \"#{TEST_TYPE}\", \"_id\" : \"#{i}\" } }", "{ \"foo\" : \"bar\"}"]
57
+ end
58
+ client.bulk(objects)
59
+ end
60
+ end
61
+
51
62
  end
52
63
  end
53
64
  end
@@ -45,6 +45,13 @@ describe ElasticSearch::Index do
45
45
  results = index.search(nil, q: '*')
46
46
  results[0].type.must_equal 'type_1'
47
47
  end
48
+
49
+ it "should search using the body" do
50
+ index[TEST_TYPE].put(1, { foo: 'bar' })
51
+ index.refresh
52
+ results = index.search({ query: { query_string: { query: '*' } } })
53
+ results.count.must_equal 1
54
+ end
48
55
  end
49
56
 
50
57
  describe :refresh do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-17 00:00:00.000000000 Z
12
+ date: 2012-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thrift
16
- requirement: &70256836637740 !ruby/object:Gem::Requirement
16
+ requirement: &70153279330420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70256836637740
24
+ version_requirements: *70153279330420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70256836637220 !ruby/object:Gem::Requirement
27
+ requirement: &70153279329780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70256836637220
35
+ version_requirements: *70153279329780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70256836636740 !ruby/object:Gem::Requirement
38
+ requirement: &70153279329160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70256836636740
46
+ version_requirements: *70153279329160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
- requirement: &70256836636060 !ruby/object:Gem::Requirement
49
+ requirement: &70153279328580 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70256836636060
57
+ version_requirements: *70153279328580
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: turn
60
- requirement: &70256836635620 !ruby/object:Gem::Requirement
60
+ requirement: &70153279328040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70256836635620
68
+ version_requirements: *70153279328040
69
69
  description: Ruby Driver for Elastic Search
70
70
  email:
71
71
  - edmund@edmundatwork.com