Skip to content

Commit

Permalink
add feature not avaialble handling to search (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Woz authored Jan 31, 2024
1 parent 23f0809 commit aa44e21
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/operations/document_search.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,18 @@ search_request::make_response(error_context::search&& ctx, const encoded_respons
response.ctx.ec = errc::common::rate_limited;
return response;
}
} else if (encoded.status_code == 404) {
tao::json::value payload{};
try {
payload = utils::json::parse(encoded.body.data());
} catch (const tao::pegtl::parse_error&) {
response.ctx.ec = errc::common::parsing_failure;
return response;
}
response.status = payload.at("status").get_string();
response.error = payload.at("error").get_string();
response.ctx.ec = errc::common::feature_not_available;
return response;
}
response.ctx.ec = errc::common::internal_server_failure;
}
Expand Down
17 changes: 17 additions & 0 deletions test/test_integration_search.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "core/operations/management/search_index_drop.hxx"
#include "core/operations/management/search_index_upsert.hxx"

#include <couchbase/match_none_query.hxx>
#include <couchbase/query_string_query.hxx>

#include <regex>
Expand Down Expand Up @@ -640,3 +641,19 @@ TEST_CASE("integration: search query collections")
REQUIRE_SUCCESS(resp.ctx.ec);
}
}

TEST_CASE("integration: scope search returns feature not available", "[integration]")
{
test::utils::integration_test_guard integration;

if (integration.cluster_version().supports_scope_search()) {
SKIP("cluster supports scope search");
}

couchbase::cluster c(integration.cluster);

auto search_request = couchbase::search_request(couchbase::match_none_query{});
auto [ctx, result] = c.bucket(integration.ctx.bucket).default_scope().search("does-not-exist", search_request).get();

REQUIRE(ctx.ec() == couchbase::errc::common::feature_not_available);
}

0 comments on commit aa44e21

Please sign in to comment.