16
16
*/
17
17
18
18
#include " test_helper_integration.hxx"
19
- #include < couchbase/operations/management/collection_create.hxx>
20
- #include < couchbase/operations/management/search_index_drop.hxx>
21
- #include < couchbase/operations/management/search_index_get_documents_count.hxx>
22
- #include < couchbase/operations/management/search_index_upsert.hxx>
23
19
24
- using Catch::Matchers::StartsWith;
20
+ #include " core/operations/management/collection_create.hxx"
21
+ #include " core/operations/management/search_index_drop.hxx"
22
+ #include " core/operations/management/search_index_get_documents_count.hxx"
23
+ #include " core/operations/management/search_index_upsert.hxx"
25
24
26
25
void
27
- wait_until_indexed (std::shared_ptr<couchbase::cluster> cluster, const std::string& index_name, std::uint64_t expected_count)
26
+ wait_until_indexed (std::shared_ptr<couchbase::core:: cluster> cluster, const std::string& index_name, std::uint64_t expected_count)
28
27
{
29
28
auto indexed = test ::utils::wait_until ([cluster = std::move (cluster), &index_name, &expected_count]() {
30
- couchbase::operations::management::search_index_get_documents_count_request req{};
29
+ couchbase::core:: operations::management::search_index_get_documents_count_request req{};
31
30
req.index_name = index_name;
32
31
req.timeout = std::chrono::seconds{ 1 };
33
32
auto resp = test::utils::execute (cluster, req);
@@ -38,18 +37,21 @@ wait_until_indexed(std::shared_ptr<couchbase::cluster> cluster, const std::strin
38
37
39
38
TEST_CASE (" integration: search query" )
40
39
{
40
+ using Catch::Matchers::StartsWith;
41
+
41
42
test::utils::integration_test_guard integration;
42
43
43
44
test::utils::open_bucket (integration.cluster , integration.ctx .bucket );
44
45
45
46
{
46
- auto sample_data = couchbase::utils::json::parse (couchbase::json_string (test::utils::read_test_data (" search_beers_dataset.json" )));
47
+ auto sample_data =
48
+ couchbase::core::utils::json::parse (couchbase::core::json_string (test::utils::read_test_data (" search_beers_dataset.json" )));
47
49
auto const & o = sample_data.get_object ();
48
50
for (const auto & [key, value] : o) {
49
- couchbase::document_id id (integration.ctx .bucket , " _default" , " _default" , key);
50
- couchbase::operations::upsert_request req{ id, couchbase::utils::json::generate (value) };
51
+ couchbase::core:: document_id id (integration.ctx .bucket , " _default" , " _default" , key);
52
+ couchbase::core:: operations::upsert_request req{ id, couchbase::core:: utils::json::generate_binary (value) };
51
53
auto resp = test::utils::execute (integration.cluster , req);
52
- REQUIRE_FALSE (resp.ctx .ec );
54
+ REQUIRE_FALSE (resp.ctx .ec () );
53
55
}
54
56
}
55
57
@@ -58,27 +60,27 @@ TEST_CASE("integration: search query")
58
60
{
59
61
auto params = test::utils::read_test_data (" search_beers_index_params.json" );
60
62
61
- couchbase::management::search::index index{};
63
+ couchbase::core:: management::search::index index{};
62
64
index.name = index_name;
63
65
index.params_json = params;
64
66
index.type = " fulltext-index" ;
65
67
index.source_name = integration.ctx .bucket ;
66
68
index.source_type = " couchbase" ;
67
- couchbase::operations::management::search_index_upsert_request req{};
69
+ couchbase::core:: operations::management::search_index_upsert_request req{};
68
70
req.index = index;
69
71
70
72
auto resp = test::utils::execute (integration.cluster , req);
71
- REQUIRE ((!resp.ctx .ec || resp.ctx .ec == couchbase::error::common_errc ::index_exists));
73
+ REQUIRE ((!resp.ctx .ec || resp.ctx .ec == couchbase::errc::common ::index_exists));
72
74
}
73
75
74
- couchbase::json_string simple_query (R"( {"query": "description:belgian"})" );
76
+ couchbase::core:: json_string simple_query (R"( {"query": "description:belgian"})" );
75
77
76
78
std::uint64_t beer_sample_doc_count = 5 ;
77
79
// Wait until expected documents are indexed
78
80
{
79
81
wait_until_indexed (integration.cluster , index_name, beer_sample_doc_count);
80
82
auto ok = test::utils::wait_until ([&]() {
81
- couchbase::operations::search_request req{};
83
+ couchbase::core:: operations::search_request req{};
82
84
req.index_name = index_name;
83
85
req.query = simple_query;
84
86
auto resp = test::utils::execute (integration.cluster , req);
@@ -90,7 +92,7 @@ TEST_CASE("integration: search query")
90
92
91
93
SECTION (" simple query" )
92
94
{
93
- couchbase::operations::search_request req{};
95
+ couchbase::core:: operations::search_request req{};
94
96
req.index_name = index_name;
95
97
req.query = simple_query;
96
98
auto resp = test::utils::execute (integration.cluster , req);
@@ -110,7 +112,7 @@ TEST_CASE("integration: search query")
110
112
111
113
SECTION (" limit" )
112
114
{
113
- couchbase::operations::search_request req{};
115
+ couchbase::core:: operations::search_request req{};
114
116
req.index_name = index_name;
115
117
req.query = simple_query;
116
118
req.limit = 1 ;
@@ -121,7 +123,7 @@ TEST_CASE("integration: search query")
121
123
122
124
SECTION (" skip" )
123
125
{
124
- couchbase::operations::search_request req{};
126
+ couchbase::core:: operations::search_request req{};
125
127
req.index_name = index_name;
126
128
req.query = simple_query;
127
129
req.skip = 1 ;
@@ -133,7 +135,7 @@ TEST_CASE("integration: search query")
133
135
134
136
SECTION (" explain" )
135
137
{
136
- couchbase::operations::search_request req{};
138
+ couchbase::core:: operations::search_request req{};
137
139
req.index_name = index_name;
138
140
req.query = simple_query;
139
141
req.explain = true ;
@@ -145,7 +147,7 @@ TEST_CASE("integration: search query")
145
147
if (integration.cluster_version ().supports_search_disable_scoring ()) {
146
148
SECTION (" disable scoring" )
147
149
{
148
- couchbase::operations::search_request req{};
150
+ couchbase::core:: operations::search_request req{};
149
151
req.index_name = index_name;
150
152
req.query = simple_query;
151
153
req.disable_scoring = true ;
@@ -158,7 +160,7 @@ TEST_CASE("integration: search query")
158
160
159
161
SECTION (" include locations" )
160
162
{
161
- couchbase::operations::search_request req{};
163
+ couchbase::core:: operations::search_request req{};
162
164
req.index_name = index_name;
163
165
req.query = simple_query;
164
166
req.include_locations = true ;
@@ -174,7 +176,7 @@ TEST_CASE("integration: search query")
174
176
175
177
SECTION (" highlight fields default highlight style" )
176
178
{
177
- couchbase::operations::search_request req{};
179
+ couchbase::core:: operations::search_request req{};
178
180
req.index_name = index_name;
179
181
req.query = simple_query;
180
182
req.highlight_fields = { " description" };
@@ -186,22 +188,22 @@ TEST_CASE("integration: search query")
186
188
SECTION (" highlight style" )
187
189
{
188
190
{
189
- couchbase::operations::search_request req{};
191
+ couchbase::core:: operations::search_request req{};
190
192
req.index_name = index_name;
191
193
req.query = simple_query;
192
194
req.highlight_fields = { " description" };
193
- req.highlight_style = couchbase::search_highlight_style::html;
195
+ req.highlight_style = couchbase::core:: search_highlight_style::html;
194
196
auto resp = test::utils::execute (integration.cluster , req);
195
197
REQUIRE_FALSE (resp.ctx .ec );
196
198
REQUIRE (resp.rows [0 ].fragments [" description" ][0 ] == " A <mark>Belgian</mark> Double Abbey." );
197
199
}
198
200
199
201
{
200
- couchbase::operations::search_request req{};
202
+ couchbase::core:: operations::search_request req{};
201
203
req.index_name = index_name;
202
204
req.query = simple_query;
203
205
req.highlight_fields = { " description" };
204
- req.highlight_style = couchbase::search_highlight_style::ansi;
206
+ req.highlight_style = couchbase::core:: search_highlight_style::ansi;
205
207
auto resp = test::utils::execute (integration.cluster , req);
206
208
REQUIRE_FALSE (resp.ctx .ec );
207
209
// TODO: is there a better way to compare ansi strings?
@@ -216,22 +218,22 @@ TEST_CASE("integration: search query")
216
218
217
219
SECTION (" fields" )
218
220
{
219
- couchbase::operations::search_request req{};
221
+ couchbase::core:: operations::search_request req{};
220
222
req.index_name = index_name;
221
223
req.query = simple_query;
222
224
req.fields .emplace_back (" description" );
223
225
auto resp = test::utils::execute (integration.cluster , req);
224
226
REQUIRE_FALSE (resp.ctx .ec );
225
- auto fields = couchbase::utils::json::parse (resp.rows [0 ].fields ).get_object ();
227
+ auto fields = couchbase::core:: utils::json::parse (resp.rows [0 ].fields ).get_object ();
226
228
REQUIRE (fields.at (" description" ).get_string () == " A Belgian Double Abbey." );
227
229
}
228
230
229
231
SECTION (" sort" )
230
232
{
231
- couchbase::operations::search_request req{};
233
+ couchbase::core:: operations::search_request req{};
232
234
req.index_name = index_name;
233
235
req.query = simple_query;
234
- req.sort_specs .emplace_back (couchbase::utils::json::generate (" _score" ));
236
+ req.sort_specs .emplace_back (couchbase::core:: utils::json::generate (" _score" ));
235
237
req.timeout = std::chrono::seconds (1 );
236
238
auto resp = test::utils::execute (integration.cluster , req);
237
239
REQUIRE_FALSE (resp.ctx .ec );
@@ -240,7 +242,7 @@ TEST_CASE("integration: search query")
240
242
241
243
SECTION (" term facet" )
242
244
{
243
- couchbase::operations::search_request req{};
245
+ couchbase::core:: operations::search_request req{};
244
246
req.index_name = index_name;
245
247
req.query = simple_query;
246
248
req.facets .insert (std::make_pair (" type" , R"( {"field": "type", "size": 1})" ));
@@ -259,7 +261,7 @@ TEST_CASE("integration: search query")
259
261
260
262
SECTION (" date range facet" )
261
263
{
262
- couchbase::operations::search_request req{};
264
+ couchbase::core:: operations::search_request req{};
263
265
req.index_name = index_name;
264
266
req.query = simple_query;
265
267
req.facets .insert (std::make_pair (
@@ -286,7 +288,7 @@ TEST_CASE("integration: search query")
286
288
287
289
SECTION (" numeric range facet" )
288
290
{
289
- couchbase::operations::search_request req{};
291
+ couchbase::core:: operations::search_request req{};
290
292
req.index_name = index_name;
291
293
req.query = simple_query;
292
294
req.facets .insert (std::make_pair (
@@ -318,11 +320,11 @@ TEST_CASE("integration: search query")
318
320
319
321
SECTION (" raw" )
320
322
{
321
- couchbase::operations::search_request req{};
323
+ couchbase::core:: operations::search_request req{};
322
324
req.index_name = index_name;
323
325
req.query = simple_query;
324
- std::map<std::string, couchbase::json_string> raw{};
325
- raw.insert (std::make_pair (" size" , couchbase::json_string (" 1" )));
326
+ std::map<std::string, couchbase::core:: json_string> raw{};
327
+ raw.insert (std::make_pair (" size" , couchbase::core:: json_string (" 1" )));
326
328
req.raw = raw;
327
329
auto resp = test::utils::execute (integration.cluster , req);
328
330
REQUIRE_FALSE (resp.ctx .ec );
@@ -357,7 +359,7 @@ TEST_CASE("integration: search query consistency", "[integration]")
357
359
auto index_name = test::utils::uniq_id (" search_index" );
358
360
359
361
{
360
- couchbase::management::search::index index{};
362
+ couchbase::core:: management::search::index index{};
361
363
index.name = index_name;
362
364
index.params_json = params;
363
365
index.type = " fulltext-index" ;
@@ -366,7 +368,7 @@ TEST_CASE("integration: search query consistency", "[integration]")
366
368
// TODO: there seems to be a server bug related to default number of partitions
367
369
// remove when it is identified and fixed
368
370
index.plan_params_json = R"( {"indexPartitions": 1})" ;
369
- couchbase::operations::management::search_index_upsert_request req{};
371
+ couchbase::core:: operations::management::search_index_upsert_request req{};
370
372
req.index = index;
371
373
auto resp = test::utils::execute (integration.cluster , req);
372
374
REQUIRE_FALSE (resp.ctx .ec );
@@ -375,26 +377,26 @@ TEST_CASE("integration: search query consistency", "[integration]")
375
377
REQUIRE (test::utils::wait_for_search_pindexes_ready (integration.cluster , integration.ctx .bucket , index_name));
376
378
377
379
auto key = test::utils::uniq_id (" key" );
378
- auto id = couchbase::document_id (integration.ctx .bucket , " _default" , " _default" , key);
380
+ auto id = couchbase::core:: document_id (integration.ctx .bucket , " _default" , " _default" , key);
379
381
auto value = test::utils::uniq_id (" value" );
380
- auto doc = couchbase::utils::json::generate (tao::json::value{
382
+ auto doc = couchbase::core:: utils::json::generate_binary (tao::json::value{
381
383
{ " value" , value },
382
384
});
383
385
384
386
couchbase::mutation_token token;
385
387
386
388
{
387
- couchbase::operations::upsert_request req{ id, doc };
389
+ couchbase::core:: operations::upsert_request req{ id, doc };
388
390
auto resp = test::utils::execute (integration.cluster , req);
389
- REQUIRE_FALSE (resp.ctx .ec );
391
+ REQUIRE_FALSE (resp.ctx .ec () );
390
392
token = resp.token ;
391
393
}
392
394
393
395
tao::json::value query{ { " query" , fmt::format (" value:{}" , value) } };
394
- auto query_json = couchbase::json_string (couchbase::utils::json::generate (query));
396
+ auto query_json = couchbase::core:: json_string (couchbase::core ::utils::json::generate (query));
395
397
396
398
{
397
- couchbase::operations::search_request req{};
399
+ couchbase::core:: operations::search_request req{};
398
400
req.index_name = index_name;
399
401
req.query = query_json;
400
402
req.mutation_state .emplace_back (token);
@@ -404,7 +406,7 @@ TEST_CASE("integration: search query consistency", "[integration]")
404
406
}
405
407
406
408
{
407
- couchbase::operations::management::search_index_drop_request req{};
409
+ couchbase::core:: operations::management::search_index_drop_request req{};
408
410
req.index_name = index_name;
409
411
test::utils::execute (integration.cluster , req);
410
412
}
@@ -427,7 +429,7 @@ TEST_CASE("integration: search query collections")
427
429
428
430
for (const auto & collection : { collection1_name, collection2_name }) {
429
431
{
430
- couchbase::operations::management::collection_create_request req{ integration.ctx .bucket , " _default" , collection };
432
+ couchbase::core:: operations::management::collection_create_request req{ integration.ctx .bucket , " _default" , collection };
431
433
auto resp = test::utils::execute (integration.cluster , req);
432
434
REQUIRE_FALSE (resp.ctx .ec );
433
435
auto created = test::utils::wait_until_collection_manifest_propagated (integration.cluster , integration.ctx .bucket , resp.uid );
@@ -436,10 +438,10 @@ TEST_CASE("integration: search query collections")
436
438
437
439
{
438
440
auto key = test::utils::uniq_id (" key" );
439
- auto id = couchbase::document_id (integration.ctx .bucket , " _default" , collection, key);
440
- couchbase::operations::upsert_request req{ id, doc };
441
+ auto id = couchbase::core:: document_id (integration.ctx .bucket , " _default" , collection, key);
442
+ couchbase::core:: operations::upsert_request req{ id, couchbase::core::utils::to_binary ( doc) };
441
443
auto resp = test::utils::execute (integration.cluster , req);
442
- REQUIRE_FALSE (resp.ctx .ec );
444
+ REQUIRE_FALSE (resp.ctx .ec () );
443
445
}
444
446
}
445
447
@@ -474,25 +476,25 @@ TEST_CASE("integration: search query collections")
474
476
)" ;
475
477
// clang-format on
476
478
477
- couchbase::management::search::index index{};
479
+ couchbase::core:: management::search::index index{};
478
480
index.name = index_name;
479
481
index.params_json = params;
480
482
index.type = " fulltext-index" ;
481
483
index.source_name = integration.ctx .bucket ;
482
484
index.source_type = " couchbase" ;
483
- couchbase::operations::management::search_index_upsert_request req{};
485
+ couchbase::core:: operations::management::search_index_upsert_request req{};
484
486
req.index = index;
485
487
auto resp = test::utils::execute (integration.cluster , req);
486
488
REQUIRE_FALSE (resp.ctx .ec );
487
489
}
488
490
489
491
wait_until_indexed (integration.cluster , index_name, 2 );
490
492
491
- couchbase::json_string simple_query (R"( {"query": "name:test"})" );
493
+ couchbase::core:: json_string simple_query (R"( {"query": "name:test"})" );
492
494
493
495
// no collections parameter - both docs returned
494
496
{
495
- couchbase::operations::search_request req{};
497
+ couchbase::core:: operations::search_request req{};
496
498
req.index_name = index_name;
497
499
req.query = simple_query;
498
500
auto resp = test::utils::execute (integration.cluster , req);
@@ -502,7 +504,7 @@ TEST_CASE("integration: search query collections")
502
504
503
505
// one collection - only docs from that collection returned
504
506
{
505
- couchbase::operations::search_request req{};
507
+ couchbase::core:: operations::search_request req{};
506
508
req.index_name = index_name;
507
509
req.query = simple_query;
508
510
req.collections .emplace_back (collection1_name);
@@ -513,7 +515,7 @@ TEST_CASE("integration: search query collections")
513
515
514
516
// two collections - both docs returned
515
517
{
516
- couchbase::operations::search_request req{};
518
+ couchbase::core:: operations::search_request req{};
517
519
req.index_name = index_name;
518
520
req.query = simple_query;
519
521
req.collections .emplace_back (collection1_name);
@@ -522,4 +524,4 @@ TEST_CASE("integration: search query collections")
522
524
REQUIRE_FALSE (resp.ctx .ec );
523
525
REQUIRE (resp.rows .size () == 2 );
524
526
}
525
- }
527
+ }
0 commit comments