elastic_adapter 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +8 -0
  3. data/lib/elastic_adapter/index.rb +16 -15
  4. data/lib/elastic_adapter/response.rb +25 -0
  5. data/lib/elastic_adapter/responses/with_aggregations.rb +9 -0
  6. data/lib/elastic_adapter/responses/with_count.rb +9 -0
  7. data/lib/elastic_adapter/responses/with_exception.rb +9 -0
  8. data/lib/elastic_adapter/responses/with_hit.rb +24 -0
  9. data/lib/elastic_adapter/responses/with_hits.rb +18 -0
  10. data/lib/elastic_adapter/responses/with_suggestions.rb +9 -0
  11. data/lib/elastic_adapter/responses/with_validations.rb +13 -0
  12. data/lib/elastic_adapter/version.rb +1 -1
  13. data/lib/elastic_adapter.rb +8 -9
  14. data/spec/cassettes/ElasticAdapter_Index/_aggregate/response/{is_a_AggregationResponse.yml → has_a_aggregation.yml} +3 -3
  15. data/spec/cassettes/ElasticAdapter_Index/_aggregate/response/is_a_WithAggregation.yml +30 -0
  16. data/spec/cassettes/ElasticAdapter_Index/_aggregate.yml +8 -8
  17. data/spec/cassettes/ElasticAdapter_Index/_count/empty_index/is_a_fixnum.yml +5 -5
  18. data/spec/cassettes/ElasticAdapter_Index/_count/empty_index/returns_the_amount_of_all_documents.yml +1 -1
  19. data/spec/cassettes/ElasticAdapter_Index/_count/empty_index.yml +2 -2
  20. data/spec/cassettes/ElasticAdapter_Index/_count/not_empty_index/is_a_fixnum.yml +5 -5
  21. data/spec/cassettes/ElasticAdapter_Index/_count/not_empty_index/returns_1.yml +1 -1
  22. data/spec/cassettes/ElasticAdapter_Index/_count/not_empty_index.yml +4 -4
  23. data/spec/cassettes/ElasticAdapter_Index/_create_index/index_is_present/response/has_an_exception.yml +1 -1
  24. data/spec/cassettes/ElasticAdapter_Index/_create_index/index_is_present/response/is_a_Response.yml +1 -1
  25. data/spec/cassettes/ElasticAdapter_Index/_create_index/index_is_present.yml +2 -2
  26. data/spec/cassettes/ElasticAdapter_Index/_create_index/index_not_present/response/has_no_exception.yml +1 -1
  27. data/spec/cassettes/ElasticAdapter_Index/_create_index/index_not_present/response/is_a_Response.yml +1 -1
  28. data/spec/cassettes/ElasticAdapter_Index/_create_index/index_not_present/response.yml +1 -1
  29. data/spec/cassettes/ElasticAdapter_Index/_delete_index/index_not_present/repsonse/has_an_exception.yml +1 -1
  30. data/spec/cassettes/ElasticAdapter_Index/_delete_index/index_not_present/repsonse/is_a_Response.yml +1 -1
  31. data/spec/cassettes/ElasticAdapter_Index/_delete_index/index_present/repsonse/has_no_exception.yml +1 -1
  32. data/spec/cassettes/ElasticAdapter_Index/_delete_index/index_present/repsonse/has_no_exceptionElasticAdapter_Index/_delete_index/index_present/repsonse.yml +1 -1
  33. data/spec/cassettes/ElasticAdapter_Index/_delete_index/index_present/repsonse/is_a_Response.yml +1 -1
  34. data/spec/cassettes/ElasticAdapter_Index/_delete_index/index_present/repsonse/is_a_ResponseElasticAdapter_Index/_delete_index/index_present/repsonse.yml +1 -1
  35. data/spec/cassettes/ElasticAdapter_Index/_get/document_exists/response/document/returns_the_document.yml +1 -1
  36. data/spec/cassettes/ElasticAdapter_Index/_get/document_exists.yml +3 -3
  37. data/spec/cassettes/ElasticAdapter_Index/_index/existing_document/doesn_t_change_the_document_count.yml +1 -55
  38. data/spec/cassettes/ElasticAdapter_Index/_index/existing_document/invokes_to_hash_on_the_document.yml +2 -2
  39. data/spec/cassettes/ElasticAdapter_Index/_index/existing_document/updates_the_document.yml +2 -2
  40. data/spec/cassettes/ElasticAdapter_Index/_index/existing_document.yml +3 -3
  41. data/spec/cassettes/ElasticAdapter_Index/_index/new_document/indexes_a_document.yml +3 -3
  42. data/spec/cassettes/ElasticAdapter_Index/_index/new_document/invokes_to_hash_on_the_document.yml +2 -2
  43. data/spec/cassettes/ElasticAdapter_Index/_index/new_document.yml +2 -2
  44. data/spec/cassettes/ElasticAdapter_Index/_search/match_all/returns_all_documents.yml +2 -2
  45. data/spec/cassettes/ElasticAdapter_Index/_search/zoo/returns_one_document.yml +3 -3
  46. data/spec/cassettes/ElasticAdapter_Index/_search/zoo/returns_the_wanted_document.yml +2 -2
  47. data/spec/cassettes/ElasticAdapter_Index/_search.yml +16 -16
  48. data/spec/cassettes/ElasticAdapter_Index/_suggest/query_ba_/returns_bar.yml +1 -1
  49. data/spec/cassettes/ElasticAdapter_Index/_suggest/query_ba_/returns_one_result.yml +1 -1
  50. data/spec/cassettes/ElasticAdapter_Index/_suggest.yml +4 -4
  51. data/spec/cassettes/ElasticAdapter_Index/_validate/invalid_query/is_a_response.yml +1 -1
  52. data/spec/cassettes/ElasticAdapter_Index/_validate/invalid_query/valid_/is_false.yml +1 -1
  53. data/spec/cassettes/ElasticAdapter_Index/_validate/valid_query/is_a_response.yml +1 -1
  54. data/spec/cassettes/ElasticAdapter_Index/_validate/valid_query/is_true.yml +1 -1
  55. data/spec/cassettes/ElasticAdapter_Index/_validate.yml +2 -2
  56. data/spec/{index → integration/index}/aggregation_spec.rb +10 -2
  57. data/spec/{index → integration/index}/count_spec.rb +5 -10
  58. data/spec/{index → integration/index}/create_index_spec.rb +0 -0
  59. data/spec/{index → integration/index}/delete_index_spec.rb +0 -0
  60. data/spec/{index → integration/index}/get_spec.rb +8 -1
  61. data/spec/integration/index/index_spec.rb +28 -0
  62. data/spec/{index → integration/index}/search_spec.rb +2 -2
  63. data/spec/{index → integration/index}/shared_context.rb +0 -0
  64. data/spec/{index → integration/index}/shared_examples.rb +2 -2
  65. data/spec/{index → integration/index}/suggest_spec.rb +2 -6
  66. data/spec/{index → integration/index}/unit_spec.rb +0 -0
  67. data/spec/{index → integration/index}/validate_spec.rb +1 -16
  68. data/spec/{document_type_spec.rb → unit/document_type_spec.rb} +0 -0
  69. data/spec/{elastic_adapter_spec.rb → unit/elastic_adapter_spec.rb} +0 -0
  70. data/spec/unit/index_spec.rb +218 -0
  71. data/spec/unit/response_spec.rb +28 -0
  72. data/spec/unit/responses/with_aggregations_spec.rb +30 -0
  73. data/spec/unit/responses/with_count_spec.rb +22 -0
  74. data/spec/unit/responses/with_exception_spec.rb +17 -0
  75. data/spec/unit/responses/with_hit_spec.rb +49 -0
  76. data/spec/unit/responses/with_hits_spec.rb +79 -0
  77. data/spec/unit/responses/with_suggestions_spec.rb +33 -0
  78. data/spec/unit/responses/with_validations_spec.rb +34 -0
  79. metadata +61 -65
  80. data/lib/elastic_adapter/responses/aggregation_response.rb +0 -28
  81. data/lib/elastic_adapter/responses/base_response.rb +0 -28
  82. data/lib/elastic_adapter/responses/count_response.rb +0 -13
  83. data/lib/elastic_adapter/responses/get_response.rb +0 -13
  84. data/lib/elastic_adapter/responses/response_decorator_factory.rb +0 -28
  85. data/lib/elastic_adapter/responses/sanitized_response.rb +0 -46
  86. data/lib/elastic_adapter/responses/search_response.rb +0 -33
  87. data/lib/elastic_adapter/responses/suggestion_response.rb +0 -46
  88. data/lib/elastic_adapter/responses/validation_response.rb +0 -18
  89. data/spec/cassettes/ElasticAdapter_Index/_count/empty_index/is_a_response.yml +0 -30
  90. data/spec/cassettes/ElasticAdapter_Index/_count/empty_index/number.yml +0 -57
  91. data/spec/cassettes/ElasticAdapter_Index/_count/not_empty_index/is_a_response.yml +0 -30
  92. data/spec/index/index_spec.rb +0 -60
  93. data/spec/responses/aggregation_response_spec.rb +0 -57
  94. data/spec/responses/base_response_spec.rb +0 -19
  95. data/spec/responses/count_response_spec.rb +0 -24
  96. data/spec/responses/get_response_spec.rb +0 -29
  97. data/spec/responses/response_decorator_factory_spec.rb +0 -126
  98. data/spec/responses/sanitized_response_spec.rb +0 -36
  99. data/spec/responses/search_response_spec.rb +0 -122
  100. data/spec/responses/suggestion_response_spec.rb +0 -63
  101. data/spec/responses/validation_response_spec.rb +0 -45
@@ -26,59 +26,5 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"count":1,"_shards":{"total":5,"successful":5,"failed":0}}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 20:12:56 GMT
30
- - request:
31
- method: put
32
- uri: http://localhost:9200/test_index/test_doc/1
33
- body:
34
- encoding: UTF-8
35
- string: '{"foo":"baz"}'
36
- headers:
37
- User-Agent:
38
- - Faraday v0.9.1
39
- Accept-Encoding:
40
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
41
- Accept:
42
- - "*/*"
43
- response:
44
- status:
45
- code: 200
46
- message: OK
47
- headers:
48
- Content-Type:
49
- - application/json; charset=UTF-8
50
- Content-Length:
51
- - '81'
52
- body:
53
- encoding: UTF-8
54
- string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":2,"created":false}'
55
- http_version:
56
- recorded_at: Sat, 07 Feb 2015 20:12:56 GMT
57
- - request:
58
- method: get
59
- uri: http://localhost:9200/test_index/_count
60
- body:
61
- encoding: UTF-8
62
- string: '{"query":{"match_all":{}}}'
63
- headers:
64
- User-Agent:
65
- - Faraday v0.9.1
66
- Accept-Encoding:
67
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
68
- Accept:
69
- - "*/*"
70
- response:
71
- status:
72
- code: 200
73
- message: OK
74
- headers:
75
- Content-Type:
76
- - application/json; charset=UTF-8
77
- Content-Length:
78
- - '59'
79
- body:
80
- encoding: UTF-8
81
- string: '{"count":1,"_shards":{"total":5,"successful":5,"failed":0}}'
82
- http_version:
83
- recorded_at: Sat, 07 Feb 2015 20:12:56 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:27 GMT
84
30
  recorded_with: VCR 2.9.3
@@ -24,7 +24,7 @@ http_interactions:
24
24
  - '81'
25
25
  body:
26
26
  encoding: UTF-8
27
- string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":3,"created":false}'
27
+ string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":2,"created":false}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 20:12:56 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:27 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -24,7 +24,7 @@ http_interactions:
24
24
  - '102'
25
25
  body:
26
26
  encoding: UTF-8
27
- string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":3,"found":true,"_source":{"foo":"baz"}}'
27
+ string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":2,"found":true,"_source":{"foo":"baz"}}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 20:12:56 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:27 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -26,7 +26,7 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"acknowledged":true}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 20:12:50 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:21 GMT
30
30
  - request:
31
31
  method: put
32
32
  uri: http://localhost:9200/test_index/test_doc/1
@@ -53,7 +53,7 @@ http_interactions:
53
53
  encoding: UTF-8
54
54
  string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":1,"created":true}'
55
55
  http_version:
56
- recorded_at: Sat, 07 Feb 2015 20:12:53 GMT
56
+ recorded_at: Wed, 23 Sep 2015 16:34:24 GMT
57
57
  - request:
58
58
  method: delete
59
59
  uri: http://localhost:9200/test_index
@@ -80,5 +80,5 @@ http_interactions:
80
80
  encoding: UTF-8
81
81
  string: '{"acknowledged":true}'
82
82
  http_version:
83
- recorded_at: Sat, 07 Feb 2015 20:12:56 GMT
83
+ recorded_at: Wed, 23 Sep 2015 16:34:27 GMT
84
84
  recorded_with: VCR 2.9.3
@@ -24,9 +24,9 @@ http_interactions:
24
24
  - '99'
25
25
  body:
26
26
  encoding: UTF-8
27
- string: '{"_index":"test_index","_type":"test_doc","_id":"AUtlrFrTm1jcpZVj70k1","_version":1,"created":true}'
27
+ string: '{"_index":"test_index","_type":"test_doc","_id":"AU_7DkROcLMsSRqdq03I","_version":1,"created":true}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 20:12:49 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:20 GMT
30
30
  - request:
31
31
  method: get
32
32
  uri: http://localhost:9200/test_index/_count
@@ -53,5 +53,5 @@ http_interactions:
53
53
  encoding: UTF-8
54
54
  string: '{"count":1,"_shards":{"total":5,"successful":5,"failed":0}}'
55
55
  http_version:
56
- recorded_at: Sat, 07 Feb 2015 20:12:50 GMT
56
+ recorded_at: Wed, 23 Sep 2015 16:34:21 GMT
57
57
  recorded_with: VCR 2.9.3
@@ -24,7 +24,7 @@ http_interactions:
24
24
  - '99'
25
25
  body:
26
26
  encoding: UTF-8
27
- string: '{"_index":"test_index","_type":"test_doc","_id":"AUtlrF7cm1jcpZVj70k2","_version":1,"created":true}'
27
+ string: '{"_index":"test_index","_type":"test_doc","_id":"AU_7DkhdcLMsSRqdq03J","_version":1,"created":true}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 20:12:50 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:21 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -26,7 +26,7 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"acknowledged":true}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 20:12:46 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:17 GMT
30
30
  - request:
31
31
  method: delete
32
32
  uri: http://localhost:9200/test_index
@@ -53,5 +53,5 @@ http_interactions:
53
53
  encoding: UTF-8
54
54
  string: '{"acknowledged":true}'
55
55
  http_version:
56
- recorded_at: Sat, 07 Feb 2015 20:12:50 GMT
56
+ recorded_at: Wed, 23 Sep 2015 16:34:21 GMT
57
57
  recorded_with: VCR 2.9.3
@@ -24,7 +24,7 @@ http_interactions:
24
24
  - '360'
25
25
  body:
26
26
  encoding: UTF-8
27
- string: '{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"test_index","_type":"test_doc","_id":"1","_score":1.0,"_source":{"foo":"bar","foo_suggest":{"input":"bar"}}},{"_index":"test_index","_type":"test_doc","_id":"2","_score":1.0,"_source":{"foo":"zoo","foo_suggest":{"input":"zoo"}}}]}}'
27
+ string: '{"took":6,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"test_index","_type":"test_doc","_id":"1","_score":1.0,"_source":{"foo":"bar","foo_suggest":{"input":"bar"}}},{"_index":"test_index","_type":"test_doc","_id":"2","_score":1.0,"_source":{"foo":"zoo","foo_suggest":{"input":"zoo"}}}]}}'
28
28
  http_version:
29
- recorded_at: Mon, 09 Mar 2015 18:47:21 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:36 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -21,10 +21,10 @@ http_interactions:
21
21
  Content-Type:
22
22
  - application/json; charset=UTF-8
23
23
  Content-Length:
24
- - '254'
24
+ - '255'
25
25
  body:
26
26
  encoding: UTF-8
27
- string: '{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"test_index","_type":"test_doc","_id":"2","_score":0.30685282,"_source":{"foo":"zoo","foo_suggest":{"input":"zoo"}}}]}}'
27
+ string: '{"took":11,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"test_index","_type":"test_doc","_id":"2","_score":0.30685282,"_source":{"foo":"zoo","foo_suggest":{"input":"zoo"}}}]}}'
28
28
  http_version:
29
- recorded_at: Mon, 09 Mar 2015 18:47:23 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:36 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -24,7 +24,7 @@ http_interactions:
24
24
  - '254'
25
25
  body:
26
26
  encoding: UTF-8
27
- string: '{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"test_index","_type":"test_doc","_id":"2","_score":0.30685282,"_source":{"foo":"zoo","foo_suggest":{"input":"zoo"}}}]}}'
27
+ string: '{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"test_index","_type":"test_doc","_id":"2","_score":0.30685282,"_source":{"foo":"zoo","foo_suggest":{"input":"zoo"}}}]}}'
28
28
  http_version:
29
- recorded_at: Mon, 09 Mar 2015 18:47:23 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:36 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -15,18 +15,18 @@ http_interactions:
15
15
  - "*/*"
16
16
  response:
17
17
  status:
18
- code: 400
19
- message: Bad Request
18
+ code: 200
19
+ message: OK
20
20
  headers:
21
21
  Content-Type:
22
22
  - application/json; charset=UTF-8
23
23
  Content-Length:
24
- - '81'
24
+ - '21'
25
25
  body:
26
26
  encoding: UTF-8
27
- string: '{"error":"IndexAlreadyExistsException[[test_index] already exists]","status":400}'
27
+ string: '{"acknowledged":true}'
28
28
  http_version:
29
- recorded_at: Mon, 09 Mar 2015 18:47:12 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:27 GMT
30
30
  - request:
31
31
  method: put
32
32
  uri: http://localhost:9200/test_index/test_doc/1
@@ -42,18 +42,18 @@ http_interactions:
42
42
  - "*/*"
43
43
  response:
44
44
  status:
45
- code: 200
46
- message: OK
45
+ code: 201
46
+ message: Created
47
47
  headers:
48
48
  Content-Type:
49
49
  - application/json; charset=UTF-8
50
50
  Content-Length:
51
- - '81'
51
+ - '80'
52
52
  body:
53
53
  encoding: UTF-8
54
- string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":2,"created":false}'
54
+ string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":1,"created":true}'
55
55
  http_version:
56
- recorded_at: Mon, 09 Mar 2015 18:47:15 GMT
56
+ recorded_at: Wed, 23 Sep 2015 16:34:30 GMT
57
57
  - request:
58
58
  method: put
59
59
  uri: http://localhost:9200/test_index/test_doc/2
@@ -69,18 +69,18 @@ http_interactions:
69
69
  - "*/*"
70
70
  response:
71
71
  status:
72
- code: 200
73
- message: OK
72
+ code: 201
73
+ message: Created
74
74
  headers:
75
75
  Content-Type:
76
76
  - application/json; charset=UTF-8
77
77
  Content-Length:
78
- - '81'
78
+ - '80'
79
79
  body:
80
80
  encoding: UTF-8
81
- string: '{"_index":"test_index","_type":"test_doc","_id":"2","_version":2,"created":false}'
81
+ string: '{"_index":"test_index","_type":"test_doc","_id":"2","_version":1,"created":true}'
82
82
  http_version:
83
- recorded_at: Mon, 09 Mar 2015 18:47:18 GMT
83
+ recorded_at: Wed, 23 Sep 2015 16:34:33 GMT
84
84
  - request:
85
85
  method: delete
86
86
  uri: http://localhost:9200/test_index
@@ -107,5 +107,5 @@ http_interactions:
107
107
  encoding: UTF-8
108
108
  string: '{"acknowledged":true}'
109
109
  http_version:
110
- recorded_at: Mon, 09 Mar 2015 18:47:23 GMT
110
+ recorded_at: Wed, 23 Sep 2015 16:34:36 GMT
111
111
  recorded_with: VCR 2.9.3
@@ -26,5 +26,5 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"_shards":{"total":5,"successful":5,"failed":0},"foo_suggest":[{"text":"ba","offset":0,"length":2,"options":[{"text":"bar","score":1.0}]}]}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 19:44:58 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:46 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -26,5 +26,5 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"_shards":{"total":5,"successful":5,"failed":0},"foo_suggest":[{"text":"ba","offset":0,"length":2,"options":[{"text":"bar","score":1.0}]}]}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 19:44:58 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:46 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -26,7 +26,7 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"acknowledged":true}'
28
28
  http_version:
29
- recorded_at: Sat, 07 Feb 2015 19:44:49 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:36 GMT
30
30
  - request:
31
31
  method: put
32
32
  uri: http://localhost:9200/test_index/test_doc/1
@@ -53,7 +53,7 @@ http_interactions:
53
53
  encoding: UTF-8
54
54
  string: '{"_index":"test_index","_type":"test_doc","_id":"1","_version":1,"created":true}'
55
55
  http_version:
56
- recorded_at: Sat, 07 Feb 2015 19:44:52 GMT
56
+ recorded_at: Wed, 23 Sep 2015 16:34:39 GMT
57
57
  - request:
58
58
  method: put
59
59
  uri: http://localhost:9200/test_index/test_doc/2
@@ -80,7 +80,7 @@ http_interactions:
80
80
  encoding: UTF-8
81
81
  string: '{"_index":"test_index","_type":"test_doc","_id":"2","_version":1,"created":true}'
82
82
  http_version:
83
- recorded_at: Sat, 07 Feb 2015 19:44:55 GMT
83
+ recorded_at: Wed, 23 Sep 2015 16:34:43 GMT
84
84
  - request:
85
85
  method: delete
86
86
  uri: http://localhost:9200/test_index
@@ -107,5 +107,5 @@ http_interactions:
107
107
  encoding: UTF-8
108
108
  string: '{"acknowledged":true}'
109
109
  http_version:
110
- recorded_at: Sat, 07 Feb 2015 19:44:58 GMT
110
+ recorded_at: Wed, 23 Sep 2015 16:34:46 GMT
111
111
  recorded_with: VCR 2.9.3
@@ -27,5 +27,5 @@ http_interactions:
27
27
  string: '{"valid":false,"_shards":{"total":1,"successful":1,"failed":0},"explanations":[{"index":"test_index","valid":false,"error":"org.elasticsearch.index.query.QueryParsingException:
28
28
  [test_index] request does not support [asd]"}]}'
29
29
  http_version:
30
- recorded_at: Mon, 09 Mar 2015 20:01:53 GMT
30
+ recorded_at: Wed, 23 Sep 2015 16:34:49 GMT
31
31
  recorded_with: VCR 2.9.3
@@ -27,5 +27,5 @@ http_interactions:
27
27
  string: '{"valid":false,"_shards":{"total":1,"successful":1,"failed":0},"explanations":[{"index":"test_index","valid":false,"error":"org.elasticsearch.index.query.QueryParsingException:
28
28
  [test_index] request does not support [asd]"}]}'
29
29
  http_version:
30
- recorded_at: Mon, 09 Mar 2015 20:01:53 GMT
30
+ recorded_at: Wed, 23 Sep 2015 16:34:49 GMT
31
31
  recorded_with: VCR 2.9.3
@@ -26,5 +26,5 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"valid":true,"_shards":{"total":1,"successful":1,"failed":0},"explanations":[{"index":"test_index","valid":true,"explanation":"ConstantScore(*:*)"}]}'
28
28
  http_version:
29
- recorded_at: Mon, 09 Mar 2015 20:01:53 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:49 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -26,5 +26,5 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"valid":true,"_shards":{"total":1,"successful":1,"failed":0},"explanations":[{"index":"test_index","valid":true,"explanation":"ConstantScore(*:*)"}]}'
28
28
  http_version:
29
- recorded_at: Mon, 09 Mar 2015 20:01:53 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:49 GMT
30
30
  recorded_with: VCR 2.9.3
@@ -26,7 +26,7 @@ http_interactions:
26
26
  encoding: UTF-8
27
27
  string: '{"acknowledged":true}'
28
28
  http_version:
29
- recorded_at: Mon, 09 Mar 2015 20:01:50 GMT
29
+ recorded_at: Wed, 23 Sep 2015 16:34:46 GMT
30
30
  - request:
31
31
  method: delete
32
32
  uri: http://localhost:9200/test_index
@@ -53,5 +53,5 @@ http_interactions:
53
53
  encoding: UTF-8
54
54
  string: '{"acknowledged":true}'
55
55
  http_version:
56
- recorded_at: Mon, 09 Mar 2015 20:01:53 GMT
56
+ recorded_at: Wed, 23 Sep 2015 16:34:49 GMT
57
57
  recorded_with: VCR 2.9.3
@@ -25,8 +25,16 @@ module ElasticAdapter
25
25
  }
26
26
  }}
27
27
 
28
- it "is a AggregationResponse" do
29
- expect(subject.aggregate(query)).to be_a Responses::AggregationResponse
28
+ before do
29
+ @response = subject.aggregate(query)
30
+ end
31
+
32
+ it "is a WithAggregation" do
33
+ expect(@response.singleton_class).to be < Responses::WithAggregations
34
+ end
35
+
36
+ it "has a aggregation" do
37
+ expect(@response.aggregations).not_to be_empty
30
38
  end
31
39
  end
32
40
  end
@@ -10,16 +10,14 @@ module ElasticAdapter
10
10
  create_test_index
11
11
  end
12
12
 
13
+
13
14
  after :all do
14
15
  delete_test_index
15
16
  end
16
17
 
17
18
  it "returns the amount of all documents" do
18
- expect(subject.count).to eq 0
19
- end
20
-
21
- it "is a fixnum" do
22
- expect(subject.count).to be_a Fixnum
19
+ result = subject.count
20
+ expect(result.count).to eq 0
23
21
  end
24
22
  end
25
23
 
@@ -34,11 +32,8 @@ module ElasticAdapter
34
32
  end
35
33
 
36
34
  it "returns 1" do
37
- expect(subject.count).to eq 1
38
- end
39
-
40
- it "is a fixnum" do
41
- expect(subject.count).to be_a Fixnum
35
+ result = subject.count
36
+ expect(result.count).to eq 1
42
37
  end
43
38
  end
44
39
  end
@@ -21,7 +21,14 @@ module ElasticAdapter
21
21
  describe "response" do
22
22
  describe "document" do
23
23
  it "returns the document" do
24
- expect(response.document).to eq document
24
+ expected = {
25
+ _index: "test_index",
26
+ _type: "test_doc",
27
+ _id: "1",
28
+ _version: 1,
29
+ _source: { foo: "bar" }
30
+ }
31
+ expect(response.hit).to eq expected
25
32
  end
26
33
  end
27
34
  end
@@ -0,0 +1,28 @@
1
+ require_relative "./shared_context.rb"
2
+
3
+ module ElasticAdapter
4
+ describe Index do
5
+ include_context "index context"
6
+
7
+ describe "#index", :vcr do
8
+ context "new document" do
9
+ let(:document) { { foo: "bar" } }
10
+
11
+ before :all do
12
+ create_test_index
13
+ end
14
+
15
+ after :all do
16
+ delete_test_index
17
+ end
18
+
19
+ it "indexes a document" do
20
+ subject.index(document)
21
+ wait(1)
22
+ response = subject.count
23
+ expect(response.count).to eq 1
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -28,8 +28,8 @@ module ElasticAdapter
28
28
  end
29
29
 
30
30
  it "returns the wanted document" do
31
- expect(response.hits.first[:id]).to eq "2"
32
- expect(response.hits.first[:foo]).to eq "zoo"
31
+ expect(response.hits.first[:_id]).to eq "2"
32
+ expect(response.hits.first[:_source][:foo]).to eq "zoo"
33
33
  end
34
34
  end
35
35
  end
File without changes
@@ -1,6 +1,6 @@
1
1
  RSpec.shared_examples "response without exception" do
2
2
  it "is a Response" do
3
- expect(response).to be_a ElasticAdapter::Responses::SanitizedResponse
3
+ expect(response).to be_a ElasticAdapter::Response
4
4
  end
5
5
 
6
6
  it "has no exception" do
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  RSpec.shared_examples "response with exception" do
12
12
  it "is a Response" do
13
- expect(response).to be_a ElasticAdapter::Responses::SanitizedResponse
13
+ expect(response).to be_a ElasticAdapter::Response
14
14
  end
15
15
 
16
16
  it "has an exception" do
@@ -28,14 +28,10 @@ module ElasticAdapter
28
28
  }
29
29
  end
30
30
 
31
- let(:response) { subject.suggest(query)}
32
-
33
- it "returns one result" do
34
- expect(response.suggestions.first.terms.first.options.count).to eq 1
35
- end
31
+ let(:response) { subject.suggest(query) }
36
32
 
37
33
  it "returns bar" do
38
- expect(response.suggestions.first.terms.first.options.first[:text]).to eq "bar"
34
+ expect(response[:foo_suggest].first[:options].first[:text]).to eq "bar"
39
35
  end
40
36
  end
41
37
  end
File without changes
@@ -27,30 +27,15 @@ module ElasticAdapter
27
27
  expect(response.valid?).to be false
28
28
  end
29
29
  end
30
-
31
- it "is a response" do
32
- expect(response).to be_a Responses::ValidationResponse
33
- end
34
30
  end
35
31
 
36
32
  context "valid query" do
37
- let(:query) do
38
- {
39
- query: {
40
- match_all: {}
41
- }
42
- }
43
- end
44
-
33
+ let(:query) {{ query: { match_all: {} } }}
45
34
  let(:response) { subject.validate(query) }
46
35
 
47
36
  it "is true" do
48
37
  expect(response.valid?).to eq true
49
38
  end
50
-
51
- it "is a response" do
52
- expect(response).to be_a Responses::ValidationResponse
53
- end
54
39
  end
55
40
  end
56
41
  end