Skip to content

Commit aa44e21

Browse files
authored
add feature not avaialble handling to search (#513)
1 parent 23f0809 commit aa44e21

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

core/operations/document_search.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,18 @@ search_request::make_response(error_context::search&& ctx, const encoded_respons
334334
response.ctx.ec = errc::common::rate_limited;
335335
return response;
336336
}
337+
} else if (encoded.status_code == 404) {
338+
tao::json::value payload{};
339+
try {
340+
payload = utils::json::parse(encoded.body.data());
341+
} catch (const tao::pegtl::parse_error&) {
342+
response.ctx.ec = errc::common::parsing_failure;
343+
return response;
344+
}
345+
response.status = payload.at("status").get_string();
346+
response.error = payload.at("error").get_string();
347+
response.ctx.ec = errc::common::feature_not_available;
348+
return response;
337349
}
338350
response.ctx.ec = errc::common::internal_server_failure;
339351
}

test/test_integration_search.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "core/operations/management/search_index_drop.hxx"
3636
#include "core/operations/management/search_index_upsert.hxx"
3737

38+
#include <couchbase/match_none_query.hxx>
3839
#include <couchbase/query_string_query.hxx>
3940

4041
#include <regex>
@@ -640,3 +641,19 @@ TEST_CASE("integration: search query collections")
640641
REQUIRE_SUCCESS(resp.ctx.ec);
641642
}
642643
}
644+
645+
TEST_CASE("integration: scope search returns feature not available", "[integration]")
646+
{
647+
test::utils::integration_test_guard integration;
648+
649+
if (integration.cluster_version().supports_scope_search()) {
650+
SKIP("cluster supports scope search");
651+
}
652+
653+
couchbase::cluster c(integration.cluster);
654+
655+
auto search_request = couchbase::search_request(couchbase::match_none_query{});
656+
auto [ctx, result] = c.bucket(integration.ctx.bucket).default_scope().search("does-not-exist", search_request).get();
657+
658+
REQUIRE(ctx.ec() == couchbase::errc::common::feature_not_available);
659+
}

0 commit comments

Comments
 (0)