Skip to content

SDKQE-2596: Search query testing for CB++ #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/init-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ options = {
password: ENV.fetch("CB_PASSWORD", "password"),
bucket: ENV.fetch("CB_BUCKET", "default"),
sec_bucket: ENV.fetch("CB_SEC_BUCKET", ""),
server_quota: ENV.fetch("CB_SERVER_QUOTA", 2048).to_i,
server_quota: ENV.fetch("CB_SERVER_QUOTA", 3072).to_i,
index_quota: ENV.fetch("CB_INDEX_QUOTA", 256).to_i,
fts_quota: ENV.fetch("CB_FTS_QUOTA", 512).to_i,
bucket_quota: ENV.fetch("CB_BUCKET_QUOTA", 256).to_i,
enable_developer_preview: ENV.fetch("CB_DEVELOPER_PREVIEW", false).to_b,
cluster_run_nodes: ENV.fetch("CB_CLUSTER_RUN_NODES", 0).to_i,
Expand Down Expand Up @@ -126,7 +127,8 @@ services = resp['allowedServices']

api.post_form("/pools/default",
memoryQuota: options[:server_quota],
indexMemoryQuota: options[:index_quota])
indexMemoryQuota: options[:index_quota],
ftsMemoryQuota: options[:fts_quota])
api.post_form("/node/controller/setupServices", services: services.join(","))

if options[:strict_encryption]
Expand Down
7 changes: 5 additions & 2 deletions core/operations/document_search.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ search_request::encode_to(search_request::encoded_request_type& encoded, http_co
{ "vectors", { { index_name, scan_vectors } } },
};
}
if (scope_name) {
body["scope"] = scope_name.value();
if (!collections.empty()) {
body["collections"] = collections;
}

for (const auto& [key, value] : raw) {
body[key] = utils::json::parse(value);
}

encoded.type = type;
encoded.headers["content-type"] = "application/json";
encoded.method = "POST";
Expand Down
1 change: 0 additions & 1 deletion core/operations/document_search.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ struct search_request {
std::optional<couchbase::core::search_highlight_style> highlight_style{};
std::vector<std::string> highlight_fields{};
std::vector<std::string> fields{};
std::optional<std::string> scope_name{};
std::vector<std::string> collections{};

std::optional<couchbase::core::search_scan_consistency> scan_consistency{};
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ integration_test(read_replica)
integration_test(tracer)
integration_test(meter)
integration_test(transcoders)
integration_test(search)

unit_test(connection_string)
unit_test(utils)
Expand Down
70 changes: 70 additions & 0 deletions test/data/search_beers_dataset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"four_peaks_brewing-abbey_normal_ale": {
"name": "Abbey Normal Ale",
"abv": 0.0,
"ibu": 0.0,
"srm": 0.0,
"upc": 0,
"type": "beer",
"brewery_id": "four_peaks_brewing",
"updated": "2010-07-22 20:00:20",
"description": "A Belgian Double Abbey.",
"style": "Other Belgian-Style Ales",
"category": "Belgian and French Ale"
},
"avery_brewing_company-reverend_the": {
"name": "Reverend, The",
"abv": 10.0,
"ibu": 0.0,
"srm": 0.0,
"upc": 0,
"type": "beer",
"brewery_id": "avery_brewing_company",
"updated": "2010-07-22 20:00:20",
"description": "Belgian-Style Quadrupel Ale",
"style": "Belgian-Style Quadrupel",
"category": "Belgian and French Ale"
},
"dragonmead_microbrewery-dubbel_dragon": {
"name": "Dubbel Dragon",
"abv": 7.2,
"ibu": 0.0,
"srm": 0.0,
"upc": 0,
"type": "beer",
"brewery_id": "dragonmead_microbrewery",
"updated": "2010-07-22 20:00:20",
"description":
"This Dubbel style Belgian beer is created in the great Belgian tradition. Pale Malt, Caramel and Special B Malts impart a unique sweetness to this beer. The traditional Belgian yeast fully ferments the Belgian Candi Sugar to give a satisfying taste that is twice what a Belgian pale delivers.",
"style": "Other Belgian-Style Ales",
"category": "Belgian and French Ale"
},
"f_x_matt_brewing-saranac_belgian_ale": {
"name": "Saranac Belgian Ale",
"abv": 5.9,
"ibu": 0.0,
"srm": 0.0,
"upc": 0,
"type": "beer",
"brewery_id": "f_x_matt_brewing",
"updated": "2010-07-22 20:00:20",
"description":
"Saranac Belgian Ale is Deliciously Fruity. It is brewed with a generous amount of Belgian Aromatic Malt, Hand selected hops, and a traditional Belgian ale yeast. Brewed in the \"Trappist Style\".",
"style": "Other Belgian-Style Ales",
"category": "Belgian and French Ale"
},
"bear_republic_brewery-red_rocket_ale": {
"name": "Red Rocket Ale",
"abv": 6.8,
"ibu": 0.0,
"srm": 0.0,
"upc": 0,
"type": "beer",
"brewery_id": "bear_republic_brewery",
"updated": "2010-08-22 20:00:20",
"description":
"The brew of choice for mountain bikers, and adventurous types worldwide. (Are you excited now!) This fiery red ale is not for the weak at heart. It originally started out as a Scottish red ale but has taken on flavors of its own. This is a very complex recipe using five different grains to achieve its unique flavor. The caramel malt used is a mixture of Belgian Caravienne and Hugh Bairds Crystal malts. Red Rocket is a full bodied, hoppy brew which finishes on the pallet with caramel malts. Centennial and Cascade hops are used for bittering and aroma.2004 L.A. Commercial Brewing Competition, Gold Medal Winner; 2004 West Coast Commercial Brewers Competition, First Place; 2003 California State Fair, Gold MedalWinner; 2002 California State Fair, Silver Medal Winner; 2001 California State Fair Gold Medal Winner; 2001 Real Ale Festival, Chicago, Bronze Medal Winner; 2000 California State Fair, Bronze Medal Winner; 1999 Great American Beer Festival, Silver Medal Winner; 1998 Great American Beer Festival, Silver Medal Winner - og 1.067, ABV 6.8%, IBU 65+.",
"style": "American-Style Amber/Red Ale",
"category": "North American Ale"
}
}
108 changes: 108 additions & 0 deletions test/data/search_beers_index_params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"doc_config": {
"docid_prefix_delim": "",
"docid_regexp": "",
"mode": "type_field",
"type_field": "type"
},
"mapping": {
"default_analyzer": "standard",
"default_datetime_parser": "dateTimeOptional",
"default_field": "_all",
"default_mapping": {
"dynamic": true,
"enabled": false
},
"default_type": "_default",
"docvalues_dynamic": true,
"index_dynamic": false,
"store_dynamic": false,
"type_field": "_type",
"types": {
"beer": {
"dynamic": false,
"enabled": true,
"properties": {
"category": {
"enabled": true,
"dynamic": false,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "category",
"store": true,
"type": "text"
}
]
},
"description": {
"enabled": true,
"dynamic": false,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "description",
"store": true,
"type": "text"
}
]
},
"type": {
"enabled": true,
"dynamic": false,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "type",
"store": true,
"type": "text"
}
]
},
"abv": {
"enabled": true,
"dynamic": false,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "abv",
"store": true,
"type": "number"
}
]
},
"updated": {
"enabled": true,
"dynamic": false,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "updated",
"store": true,
"type": "datetime"
}
]
}
}
}
}
},
"store": {
"indexType": "scorch"
}
}
2 changes: 1 addition & 1 deletion test/test_helper.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "utils/binary.hxx"
#include "utils/test_context.hxx"
#include "utils/uniq_id.hxx"
#include "utils/test_data.hxx"

#include <catch2/catch.hpp>

Expand Down
2 changes: 1 addition & 1 deletion test/test_integration_analytics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "core/operations/management/analytics.hxx"
#include "core/operations/management/collection_create.hxx"
#include "core/operations/management/scope_create.hxx"
#include "core/operations/management/collections.hxx"
#include "test_helper_integration.hxx"

TEST_CASE("integration: analytics query")
Expand Down
2 changes: 1 addition & 1 deletion test/test_integration_management.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2414,7 +2414,7 @@ TEST_CASE("integration: search index management analyze document", "[integration
REQUIRE_SUCCESS(resp.ctx.ec);
}

REQUIRE(wait_for_search_pindexes_ready(integration, index_name));
REQUIRE(test::utils::wait_for_search_pindexes_ready(integration.cluster, integration.ctx.bucket, index_name));

couchbase::core::operations::management::search_index_analyze_document_response resp;
bool operation_completed = test::utils::wait_until([&integration, &index_name, &resp]() {
Expand Down
Loading