mirror of https://gitee.com/bigwinds/arangodb
* add more tests * and more... * address msvc build issue
This commit is contained in:
parent
1d15b50d22
commit
420326be25
|
@ -341,9 +341,10 @@ void IResearchViewExecutorBase<Impl, Traits>::reset() {
|
|||
irs::Or root;
|
||||
|
||||
auto rv = FilterFactory::filter(&root, queryCtx, infos().filterCondition());
|
||||
|
||||
if (rv.fail()) {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||
TRI_ERROR_BAD_PARAMETER,
|
||||
rv.errorNumber(),
|
||||
"failed to build filter while querying arangosearch view, query '" +
|
||||
infos().filterCondition().toVelocyPack(true)->toJson() + "': " + rv.errorMessage());
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ bool optimizeSearchCondition(IResearchViewNode& viewNode, Query& query, Executio
|
|||
);
|
||||
|
||||
if (filterCreated.fail()) {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_QUERY_PARSE,
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(filterCreated.errorNumber(),
|
||||
"unsupported SEARCH condition: " + filterCreated.errorMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1438,6 +1438,7 @@ arangodb::Result fromFuncMinMatch(irs::boolean_filter* filter, QueryContext cons
|
|||
if (argc < 2) {
|
||||
auto message = "'MIN_MATCH' AQL function: Invalid number of arguments passed (must be >= 2)";
|
||||
LOG_TOPIC("6c8d4", WARN, arangodb::iresearch::TOPIC) << message;
|
||||
return {TRI_ERROR_BAD_PARAMETER, message};
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
|
@ -2082,9 +2083,7 @@ namespace iresearch {
|
|||
// The analyzer is referenced in the FilterContext and used during the
|
||||
// following ::filter() call, so may not be a temporary.
|
||||
IResearchLinkMeta::Analyzer analyzer = IResearchLinkMeta::Analyzer();
|
||||
FilterContext const filterCtx( // context
|
||||
analyzer, irs::no_boost() // args
|
||||
);
|
||||
FilterContext const filterCtx(analyzer, irs::no_boost());
|
||||
|
||||
return ::filter(filter, ctx, filterCtx, node);
|
||||
}
|
||||
|
|
|
@ -138,9 +138,11 @@ set(ARANGODB_TESTS_SOURCES
|
|||
IResearch/IResearchQueryBooleanTerm-test.cpp
|
||||
IResearch/IResearchQueryComplexBoolean-test.cpp
|
||||
IResearch/IResearchQueryExists-test.cpp
|
||||
IResearch/IResearchQueryFilter-test.cpp
|
||||
IResearch/IResearchQueryIn-test.cpp
|
||||
IResearch/IResearchQueryInRange-test.cpp
|
||||
IResearch/IResearchQueryJoin-test.cpp
|
||||
IResearch/IResearchQueryMinMatch-test.cpp
|
||||
IResearch/IResearchQueryNullTerm-test.cpp
|
||||
IResearch/IResearchQueryNumericTerm-test.cpp
|
||||
IResearch/IResearchQueryOptimization-test.cpp
|
||||
|
|
|
@ -0,0 +1,371 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2019 ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Andrey Abramov
|
||||
/// @author Vasiliy Nabatchikov
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "common.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "../Mocks/StorageEngineMock.h"
|
||||
|
||||
#if USE_ENTERPRISE
|
||||
#include "Enterprise/Ldap/LdapFeature.h"
|
||||
#endif
|
||||
|
||||
#include "3rdParty/iresearch/tests/tests_config.hpp"
|
||||
#include "Aql/AqlFunctionFeature.h"
|
||||
#include "Aql/Ast.h"
|
||||
#include "Aql/ExpressionContext.h"
|
||||
#include "Aql/OptimizerRulesFeature.h"
|
||||
#include "Aql/Query.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "GeneralServer/AuthenticationFeature.h"
|
||||
#include "IResearch/IResearchAnalyzerFeature.h"
|
||||
#include "IResearch/IResearchCommon.h"
|
||||
#include "IResearch/IResearchFeature.h"
|
||||
#include "IResearch/IResearchFilterFactory.h"
|
||||
#include "IResearch/IResearchView.h"
|
||||
#include "Logger/LogTopic.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "RestServer/AqlFeature.h"
|
||||
#include "RestServer/DatabaseFeature.h"
|
||||
#include "RestServer/DatabasePathFeature.h"
|
||||
#include "RestServer/QueryRegistryFeature.h"
|
||||
#include "RestServer/SystemDatabaseFeature.h"
|
||||
#include "RestServer/TraverserEngineRegistryFeature.h"
|
||||
#include "RestServer/ViewTypesFeature.h"
|
||||
#include "Sharding/ShardingFeature.h"
|
||||
#include "StorageEngine/EngineSelectorFeature.h"
|
||||
#include "Transaction/Helpers.h"
|
||||
#include "Transaction/Methods.h"
|
||||
#include "Transaction/StandaloneContext.h"
|
||||
#include "Utils/OperationOptions.h"
|
||||
#include "V8/v8-globals.h"
|
||||
#include "VocBase/LogicalCollection.h"
|
||||
#include "VocBase/LogicalView.h"
|
||||
#include "VocBase/ManagedDocumentResult.h"
|
||||
|
||||
#include "IResearch/VelocyPackHelper.h"
|
||||
#include "analysis/analyzers.hpp"
|
||||
#include "analysis/token_attributes.hpp"
|
||||
#include "utils/utf8_path.hpp"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
|
||||
extern const char* ARGV0; // defined in main.cpp
|
||||
|
||||
namespace {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- setup / tear-down
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class IResearchQueryFilterTest : public ::testing::Test {
|
||||
protected:
|
||||
StorageEngineMock engine;
|
||||
arangodb::application_features::ApplicationServer server;
|
||||
std::unique_ptr<TRI_vocbase_t> system;
|
||||
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
|
||||
|
||||
IResearchQueryFilterTest() : engine(server), server(nullptr, nullptr) {
|
||||
arangodb::EngineSelectorFeature::ENGINE = &engine;
|
||||
arangodb::aql::AqlFunctionFeature* functions = nullptr;
|
||||
|
||||
arangodb::tests::init(true);
|
||||
|
||||
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
|
||||
// suppress WARNING {authentication} --server.jwt-secret is insecure. Use --server.jwt-secret-keyfile instead
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(),
|
||||
arangodb::LogLevel::ERR);
|
||||
|
||||
// suppress log messages since tests check error conditions
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
|
||||
arangodb::LogTopic::setLogLevel(arangodb::iresearch::TOPIC.name(),
|
||||
arangodb::LogLevel::FATAL);
|
||||
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
|
||||
|
||||
// setup required application features
|
||||
features.emplace_back(new arangodb::ViewTypesFeature(server), true);
|
||||
features.emplace_back(new arangodb::AuthenticationFeature(server), true);
|
||||
features.emplace_back(new arangodb::DatabasePathFeature(server), false);
|
||||
features.emplace_back(new arangodb::DatabaseFeature(server), false);
|
||||
features.emplace_back(new arangodb::ShardingFeature(server), false);
|
||||
features.emplace_back(new arangodb::QueryRegistryFeature(server), false); // must be first
|
||||
arangodb::application_features::ApplicationServer::server->addFeature(
|
||||
features.back().first); // need QueryRegistryFeature feature to be added now in order to create the system database
|
||||
system = irs::memory::make_unique<TRI_vocbase_t>(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL,
|
||||
0, TRI_VOC_SYSTEM_DATABASE);
|
||||
features.emplace_back(new arangodb::SystemDatabaseFeature(server, system.get()),
|
||||
false); // required for IResearchAnalyzerFeature
|
||||
features.emplace_back(new arangodb::TraverserEngineRegistryFeature(server), false); // must be before AqlFeature
|
||||
features.emplace_back(new arangodb::AqlFeature(server), true);
|
||||
features.emplace_back(new arangodb::aql::OptimizerRulesFeature(server), true);
|
||||
features.emplace_back(functions = new arangodb::aql::AqlFunctionFeature(server),
|
||||
true); // required for IResearchAnalyzerFeature
|
||||
features.emplace_back(new arangodb::iresearch::IResearchAnalyzerFeature(server), true);
|
||||
features.emplace_back(new arangodb::iresearch::IResearchFeature(server), true);
|
||||
|
||||
#if USE_ENTERPRISE
|
||||
features.emplace_back(new arangodb::LdapFeature(server),
|
||||
false); // required for AuthenticationFeature with USE_ENTERPRISE
|
||||
#endif
|
||||
|
||||
for (auto& f : features) {
|
||||
arangodb::application_features::ApplicationServer::server->addFeature(f.first);
|
||||
}
|
||||
|
||||
for (auto& f : features) {
|
||||
f.first->prepare();
|
||||
}
|
||||
|
||||
for (auto& f : features) {
|
||||
if (f.second) {
|
||||
f.first->start();
|
||||
}
|
||||
}
|
||||
|
||||
// register fake non-deterministic function in order to suppress optimizations
|
||||
functions->add(arangodb::aql::Function{
|
||||
"_NONDETERM_", ".",
|
||||
arangodb::aql::Function::makeFlags(
|
||||
// fake non-deterministic
|
||||
arangodb::aql::Function::Flags::CanRunOnDBServer),
|
||||
[](arangodb::aql::ExpressionContext*, arangodb::transaction::Methods*,
|
||||
arangodb::aql::VPackFunctionParameters const& params) {
|
||||
TRI_ASSERT(!params.empty());
|
||||
return params[0];
|
||||
}});
|
||||
|
||||
// register fake non-deterministic function in order to suppress optimizations
|
||||
functions->add(arangodb::aql::Function{
|
||||
"_FORWARD_", ".",
|
||||
arangodb::aql::Function::makeFlags(
|
||||
// fake deterministic
|
||||
arangodb::aql::Function::Flags::Deterministic, arangodb::aql::Function::Flags::Cacheable,
|
||||
arangodb::aql::Function::Flags::CanRunOnDBServer),
|
||||
[](arangodb::aql::ExpressionContext*, arangodb::transaction::Methods*,
|
||||
arangodb::aql::VPackFunctionParameters const& params) {
|
||||
TRI_ASSERT(!params.empty());
|
||||
return params[0];
|
||||
}});
|
||||
|
||||
auto* dbPathFeature =
|
||||
arangodb::application_features::ApplicationServer::getFeature<arangodb::DatabasePathFeature>(
|
||||
"DatabasePath");
|
||||
arangodb::tests::setDatabasePath(*dbPathFeature); // ensure test data is stored in a unique directory
|
||||
}
|
||||
|
||||
~IResearchQueryFilterTest() {
|
||||
system.reset(); // destroy before reseting the 'ENGINE'
|
||||
arangodb::AqlFeature(server).stop(); // unset singleton instance
|
||||
arangodb::LogTopic::setLogLevel(arangodb::iresearch::TOPIC.name(),
|
||||
arangodb::LogLevel::DEFAULT);
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(),
|
||||
arangodb::LogLevel::DEFAULT);
|
||||
arangodb::application_features::ApplicationServer::server = nullptr;
|
||||
arangodb::EngineSelectorFeature::ENGINE = nullptr;
|
||||
|
||||
// destroy application features
|
||||
for (auto& f : features) {
|
||||
if (f.second) {
|
||||
f.first->stop();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& f : features) {
|
||||
f.first->unprepare();
|
||||
}
|
||||
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(),
|
||||
arangodb::LogLevel::DEFAULT);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- test suite
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
TEST_F(IResearchQueryFilterTest, SearchAndFilter) {
|
||||
// ==, !=, <, <=, >, >=, range
|
||||
static std::vector<std::string> const EMPTY;
|
||||
|
||||
auto createJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \
|
||||
\"name\": \"testView\", \
|
||||
\"type\": \"arangosearch\" \
|
||||
}");
|
||||
|
||||
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1,
|
||||
"testVocbase");
|
||||
std::shared_ptr<arangodb::LogicalCollection> logicalCollection1;
|
||||
std::shared_ptr<arangodb::LogicalCollection> logicalCollection2;
|
||||
|
||||
// add collection_1
|
||||
{
|
||||
auto collectionJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"name\": \"collection_1\" }");
|
||||
logicalCollection1 = vocbase.createCollection(collectionJson->slice());
|
||||
ASSERT_TRUE((nullptr != logicalCollection1));
|
||||
}
|
||||
|
||||
// add collection_2
|
||||
{
|
||||
auto collectionJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"name\": \"collection_2\" }");
|
||||
logicalCollection2 = vocbase.createCollection(collectionJson->slice());
|
||||
ASSERT_TRUE((nullptr != logicalCollection2));
|
||||
}
|
||||
|
||||
// add collection_3
|
||||
{
|
||||
auto collectionJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"name\": \"collection_3\" }");
|
||||
auto logicalCollection3 = vocbase.createCollection(collectionJson->slice());
|
||||
ASSERT_TRUE((nullptr != logicalCollection3));
|
||||
}
|
||||
|
||||
// add view
|
||||
auto view = std::dynamic_pointer_cast<arangodb::iresearch::IResearchView>(
|
||||
vocbase.createView(createJson->slice()));
|
||||
ASSERT_TRUE((false == !view));
|
||||
|
||||
// add link to collection
|
||||
{
|
||||
auto updateJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"links\" : {"
|
||||
"\"collection_1\" : { \"includeAllFields\" : true },"
|
||||
"\"collection_2\" : { \"includeAllFields\" : true }"
|
||||
"}}");
|
||||
EXPECT_TRUE((view->properties(updateJson->slice(), true).ok()));
|
||||
|
||||
arangodb::velocypack::Builder builder;
|
||||
|
||||
builder.openObject();
|
||||
view->properties(builder, arangodb::LogicalDataSource::makeFlags(
|
||||
arangodb::LogicalDataSource::Serialize::Detailed));
|
||||
builder.close();
|
||||
|
||||
auto slice = builder.slice();
|
||||
EXPECT_TRUE(slice.isObject());
|
||||
EXPECT_TRUE(slice.get("name").copyString() == "testView");
|
||||
EXPECT_TRUE(slice.get("type").copyString() ==
|
||||
arangodb::iresearch::DATA_SOURCE_TYPE.name());
|
||||
EXPECT_TRUE(slice.get("deleted").isNone()); // no system properties
|
||||
auto tmpSlice = slice.get("links");
|
||||
EXPECT_TRUE((true == tmpSlice.isObject() && 2 == tmpSlice.length()));
|
||||
}
|
||||
|
||||
std::deque<arangodb::ManagedDocumentResult> insertedDocs;
|
||||
|
||||
// populate view with the data
|
||||
{
|
||||
arangodb::OperationOptions opt;
|
||||
|
||||
arangodb::transaction::Methods trx(arangodb::transaction::StandaloneContext::Create(vocbase),
|
||||
EMPTY, EMPTY, EMPTY,
|
||||
arangodb::transaction::Options());
|
||||
EXPECT_TRUE((trx.begin().ok()));
|
||||
|
||||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource /= irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource /= irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder =
|
||||
arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
auto root = builder.slice();
|
||||
ASSERT_TRUE(root.isArray());
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
std::shared_ptr<arangodb::LogicalCollection> collections[]{logicalCollection1,
|
||||
logicalCollection2};
|
||||
|
||||
for (auto doc : arangodb::velocypack::ArrayIterator(root)) {
|
||||
insertedDocs.emplace_back();
|
||||
auto const res =
|
||||
collections[i%2]->insert(&trx, doc, insertedDocs.back(), opt, false);
|
||||
EXPECT_TRUE(res.ok());
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_TRUE((trx.commit().ok()));
|
||||
EXPECT_TRUE(
|
||||
(arangodb::tests::executeQuery(vocbase,
|
||||
"FOR d IN testView SEARCH 1 ==1 OPTIONS "
|
||||
"{ waitForSync: true } RETURN d")
|
||||
.result.ok())); // commit
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- 'collections' option
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// collection by name
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH d.name == 'A' || d.name == 'B' "
|
||||
"FILTER d.seq == 0 "
|
||||
"RETURN d";
|
||||
|
||||
EXPECT_TRUE(arangodb::tests::assertRules(
|
||||
vocbase, query, {arangodb::aql::OptimizerRule::handleArangoSearchViewsRule}));
|
||||
|
||||
std::map<irs::string_ref, arangodb::ManagedDocumentResult const*> expectedDocs{
|
||||
{"A", &insertedDocs[0]}};
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_TRUE(queryResult.result.ok());
|
||||
|
||||
auto result = queryResult.data->slice();
|
||||
EXPECT_TRUE(result.isArray());
|
||||
|
||||
arangodb::velocypack::ArrayIterator resultIt(result);
|
||||
ASSERT_EQ(expectedDocs.size(), resultIt.size());
|
||||
|
||||
for (auto const actualDoc : resultIt) {
|
||||
auto const resolved = actualDoc.resolveExternals();
|
||||
auto const keySlice = resolved.get("name");
|
||||
auto const key = arangodb::iresearch::getStringRef(keySlice);
|
||||
|
||||
auto expectedDoc = expectedDocs.find(key);
|
||||
ASSERT_TRUE(expectedDoc != expectedDocs.end());
|
||||
EXPECT_TRUE(0 == arangodb::basics::VelocyPackHelper::compare(
|
||||
arangodb::velocypack::Slice(expectedDoc->second->vpack()),
|
||||
resolved, true));
|
||||
expectedDocs.erase(expectedDoc);
|
||||
}
|
||||
EXPECT_TRUE(expectedDocs.empty());
|
||||
}
|
||||
|
||||
// FILTER must always follow SEARCH
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView FILTER d.seq == 1' SEARCH d.name == 'A' RETURN d";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
}
|
||||
}
|
|
@ -292,7 +292,7 @@ TEST_F(IResearchQueryInTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH d.value IN [ [ -1, 0 ], [ 1, \"abc\" ] ] "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test array via []
|
||||
|
@ -301,7 +301,7 @@ TEST_F(IResearchQueryInTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH d['value'] IN [ [ -1, 0 ], [ 1, \"abc\" ] ] "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test bool
|
||||
|
@ -486,7 +486,7 @@ TEST_F(IResearchQueryInTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH d.value IN [ { \"a\": 7, \"b\": \"c\" } ] "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test object via []
|
||||
|
@ -498,7 +498,7 @@ TEST_F(IResearchQueryInTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH d['value'] IN [ {}, { \"a\": 7, \"b\": \"c\" "
|
||||
"} ] SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test string
|
||||
|
|
|
@ -0,0 +1,681 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2017 ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Andrey Abramov
|
||||
/// @author Vasiliy Nabatchikov
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "common.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "../Mocks/StorageEngineMock.h"
|
||||
|
||||
#if USE_ENTERPRISE
|
||||
#include "Enterprise/Ldap/LdapFeature.h"
|
||||
#endif
|
||||
|
||||
#include "3rdParty/iresearch/tests/tests_config.hpp"
|
||||
#include "Aql/AqlFunctionFeature.h"
|
||||
#include "Aql/Ast.h"
|
||||
#include "Aql/OptimizerRulesFeature.h"
|
||||
#include "Aql/Query.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Cluster/ClusterFeature.h"
|
||||
#include "GeneralServer/AuthenticationFeature.h"
|
||||
#include "IResearch/IResearchAnalyzerFeature.h"
|
||||
#include "IResearch/IResearchCommon.h"
|
||||
#include "IResearch/IResearchFeature.h"
|
||||
#include "IResearch/IResearchFilterFactory.h"
|
||||
#include "IResearch/IResearchView.h"
|
||||
#include "Logger/LogTopic.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "RestServer/AqlFeature.h"
|
||||
#include "RestServer/DatabaseFeature.h"
|
||||
#include "RestServer/DatabasePathFeature.h"
|
||||
#include "RestServer/QueryRegistryFeature.h"
|
||||
#include "RestServer/SystemDatabaseFeature.h"
|
||||
#include "RestServer/TraverserEngineRegistryFeature.h"
|
||||
#include "RestServer/ViewTypesFeature.h"
|
||||
#include "Sharding/ShardingFeature.h"
|
||||
#include "StorageEngine/EngineSelectorFeature.h"
|
||||
#include "Transaction/StandaloneContext.h"
|
||||
#include "Utils/OperationOptions.h"
|
||||
#include "Utils/SingleCollectionTransaction.h"
|
||||
#include "V8/v8-globals.h"
|
||||
#include "V8Server/V8DealerFeature.h"
|
||||
#include "VocBase/LogicalCollection.h"
|
||||
#include "VocBase/LogicalView.h"
|
||||
#include "VocBase/Methods/Collections.h"
|
||||
|
||||
#include "IResearch/VelocyPackHelper.h"
|
||||
#include "analysis/analyzers.hpp"
|
||||
#include "analysis/token_attributes.hpp"
|
||||
#include "utils/utf8_path.hpp"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
|
||||
extern const char* ARGV0; // defined in main.cpp
|
||||
|
||||
namespace {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- setup / tear-down
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class IResearchQueryMinMatchTest : public ::testing::Test {
|
||||
protected:
|
||||
StorageEngineMock engine;
|
||||
arangodb::application_features::ApplicationServer server;
|
||||
std::vector<std::pair<arangodb::application_features::ApplicationFeature*, bool>> features;
|
||||
TRI_vocbase_t* sysVocBase{};
|
||||
|
||||
IResearchQueryMinMatchTest() : engine(server), server(nullptr, nullptr) {
|
||||
arangodb::EngineSelectorFeature::ENGINE = &engine;
|
||||
|
||||
arangodb::tests::init(true);
|
||||
|
||||
// suppress INFO {authentication} Authentication is turned on (system only), authentication for unix sockets is turned on
|
||||
// suppress WARNING {authentication} --server.jwt-secret is insecure. Use --server.jwt-secret-keyfile instead
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(),
|
||||
arangodb::LogLevel::ERR);
|
||||
|
||||
// suppress log messages since tests check error conditions
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::AQL.name(), arangodb::LogLevel::ERR); // suppress WARNING {aql} Suboptimal AqlItemMatrix index lookup:
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
|
||||
arangodb::LogTopic::setLogLevel(arangodb::iresearch::TOPIC.name(),
|
||||
arangodb::LogLevel::FATAL);
|
||||
irs::logger::output_le(iresearch::logger::IRL_FATAL, stderr);
|
||||
|
||||
// setup required application features
|
||||
features.emplace_back(new arangodb::V8DealerFeature(server),
|
||||
false); // required for DatabaseFeature::createDatabase(...)
|
||||
features.emplace_back(new arangodb::ViewTypesFeature(server), true);
|
||||
features.emplace_back(new arangodb::AuthenticationFeature(server), true);
|
||||
features.emplace_back(new arangodb::DatabasePathFeature(server), false);
|
||||
features.emplace_back(new arangodb::DatabaseFeature(server), false);
|
||||
features.emplace_back(new arangodb::ShardingFeature(server), false);
|
||||
features.emplace_back(new arangodb::QueryRegistryFeature(server), false); // must be first
|
||||
arangodb::application_features::ApplicationServer::server->addFeature(
|
||||
features.back().first); // need QueryRegistryFeature feature to be added now in order to create the system database
|
||||
features.emplace_back(new arangodb::SystemDatabaseFeature(server), true); // required for IResearchAnalyzerFeature
|
||||
features.emplace_back(new arangodb::TraverserEngineRegistryFeature(server), false); // must be before AqlFeature
|
||||
features.emplace_back(new arangodb::AqlFeature(server), true);
|
||||
features.emplace_back(new arangodb::aql::OptimizerRulesFeature(server), true);
|
||||
features.emplace_back(new arangodb::aql::AqlFunctionFeature(server), true); // required for IResearchAnalyzerFeature
|
||||
features.emplace_back(new arangodb::iresearch::IResearchAnalyzerFeature(server), true);
|
||||
features.emplace_back(new arangodb::iresearch::IResearchFeature(server), true);
|
||||
|
||||
#if USE_ENTERPRISE
|
||||
features.emplace_back(new arangodb::LdapFeature(server),
|
||||
false); // required for AuthenticationFeature with USE_ENTERPRISE
|
||||
#endif
|
||||
|
||||
// required for V8DealerFeature::prepare(), ClusterFeature::prepare() not required
|
||||
arangodb::application_features::ApplicationServer::server->addFeature(
|
||||
new arangodb::ClusterFeature(server));
|
||||
|
||||
for (auto& f : features) {
|
||||
arangodb::application_features::ApplicationServer::server->addFeature(f.first);
|
||||
}
|
||||
|
||||
for (auto& f : features) {
|
||||
f.first->prepare();
|
||||
}
|
||||
|
||||
auto const databases = arangodb::velocypack::Parser::fromJson(
|
||||
std::string("[ { \"name\": \"") +
|
||||
arangodb::StaticStrings::SystemDatabase + "\" } ]");
|
||||
auto* dbFeature =
|
||||
arangodb::application_features::ApplicationServer::lookupFeature<arangodb::DatabaseFeature>(
|
||||
"Database");
|
||||
dbFeature->loadDatabases(databases->slice());
|
||||
|
||||
for (auto& f : features) {
|
||||
if (f.second) {
|
||||
f.first->start();
|
||||
}
|
||||
}
|
||||
|
||||
auto* sysVocBaseFeature =
|
||||
arangodb::application_features::ApplicationServer::lookupFeature<arangodb::SystemDatabaseFeature>();
|
||||
EXPECT_TRUE(sysVocBaseFeature);
|
||||
|
||||
auto sysVocBasePtr = sysVocBaseFeature->use();
|
||||
arangodb::methods::Collections::createSystem(
|
||||
*sysVocBasePtr,
|
||||
arangodb::tests::AnalyzerCollectionName);
|
||||
|
||||
auto* analyzers =
|
||||
arangodb::application_features::ApplicationServer::lookupFeature<arangodb::iresearch::IResearchAnalyzerFeature>();
|
||||
arangodb::iresearch::IResearchAnalyzerFeature::EmplaceResult result;
|
||||
TRI_vocbase_t* vocbase;
|
||||
|
||||
dbFeature->createDatabase(1, "testVocbase", vocbase); // required for IResearchAnalyzerFeature::emplace(...)
|
||||
arangodb::methods::Collections::createSystem(
|
||||
*vocbase,
|
||||
arangodb::tests::AnalyzerCollectionName);
|
||||
analyzers->emplace(result, "testVocbase::test_analyzer", "TestAnalyzer",
|
||||
VPackParser::fromJson("\"abc\"")->slice(),
|
||||
irs::flags{irs::frequency::type(), irs::position::type()} // required for PHRASE
|
||||
); // cache analyzer
|
||||
|
||||
analyzers->emplace(result, "testVocbase::test_csv_analyzer",
|
||||
"TestDelimAnalyzer",
|
||||
VPackParser::fromJson("\",\"")->slice()); // cache analyzer
|
||||
|
||||
analyzers->emplace(result, "_system::test_analyzer", "TestAnalyzer",
|
||||
VPackParser::fromJson("\"abc\"")->slice(),
|
||||
irs::flags{irs::frequency::type(), irs::position::type()} // required for PHRASE
|
||||
); // cache analyzer
|
||||
|
||||
analyzers->emplace(result, "_system::test_csv_analyzer", "TestDelimAnalyzer",
|
||||
VPackParser::fromJson("\",\"")->slice()); // cache analyzer
|
||||
|
||||
auto* dbPathFeature =
|
||||
arangodb::application_features::ApplicationServer::getFeature<arangodb::DatabasePathFeature>(
|
||||
"DatabasePath");
|
||||
arangodb::tests::setDatabasePath(*dbPathFeature); // ensure test data is stored in a unique directory
|
||||
}
|
||||
|
||||
~IResearchQueryMinMatchTest() {
|
||||
arangodb::AqlFeature(server).stop(); // unset singleton instance
|
||||
arangodb::LogTopic::setLogLevel(arangodb::iresearch::TOPIC.name(),
|
||||
arangodb::LogLevel::DEFAULT);
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(),
|
||||
arangodb::LogLevel::DEFAULT);
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::AQL.name(), arangodb::LogLevel::DEFAULT);
|
||||
arangodb::application_features::ApplicationServer::server = nullptr;
|
||||
|
||||
// destroy application features
|
||||
for (auto& f : features) {
|
||||
if (f.second) {
|
||||
f.first->stop();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& f : features) {
|
||||
f.first->unprepare();
|
||||
}
|
||||
|
||||
arangodb::LogTopic::setLogLevel(arangodb::Logger::AUTHENTICATION.name(),
|
||||
arangodb::LogLevel::DEFAULT);
|
||||
arangodb::EngineSelectorFeature::ENGINE = nullptr;
|
||||
}
|
||||
}; // IResearchQueryMinMatchTest
|
||||
|
||||
} // namespace
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- test suite
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
TEST_F(IResearchQueryMinMatchTest, test) {
|
||||
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1,
|
||||
"testVocbase");
|
||||
std::vector<arangodb::velocypack::Builder> insertedDocs;
|
||||
arangodb::LogicalView* view;
|
||||
|
||||
// create collection0
|
||||
{
|
||||
auto createJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"name\": \"testCollection0\" }");
|
||||
auto collection = vocbase.createCollection(createJson->slice());
|
||||
ASSERT_TRUE((nullptr != collection));
|
||||
|
||||
std::vector<std::shared_ptr<arangodb::velocypack::Builder>> docs{
|
||||
arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"seq\": -6, \"value\": null }"),
|
||||
arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"seq\": -5, \"value\": true }"),
|
||||
arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"seq\": -4, \"value\": \"abc\" }"),
|
||||
arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"seq\": -3, \"value\": 3.14 }"),
|
||||
arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"seq\": -2, \"value\": [ 1, \"abc\" ] }"),
|
||||
arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"seq\": -1, \"value\": { \"a\": 7, \"b\": \"c\" } }"),
|
||||
};
|
||||
|
||||
arangodb::OperationOptions options;
|
||||
options.returnNew = true;
|
||||
arangodb::SingleCollectionTransaction trx(arangodb::transaction::StandaloneContext::Create(vocbase),
|
||||
*collection,
|
||||
arangodb::AccessMode::Type::WRITE);
|
||||
EXPECT_TRUE((trx.begin().ok()));
|
||||
|
||||
for (auto& entry : docs) {
|
||||
auto res = trx.insert(collection->name(), entry->slice(), options);
|
||||
EXPECT_TRUE((res.ok()));
|
||||
insertedDocs.emplace_back(res.slice().get("new"));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((trx.commit().ok()));
|
||||
}
|
||||
|
||||
// create collection1
|
||||
{
|
||||
auto createJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"name\": \"testCollection1\" }");
|
||||
auto collection = vocbase.createCollection(createJson->slice());
|
||||
ASSERT_TRUE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource /= irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource /= irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder =
|
||||
arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
auto slice = builder.slice();
|
||||
ASSERT_TRUE(slice.isArray());
|
||||
|
||||
arangodb::OperationOptions options;
|
||||
options.returnNew = true;
|
||||
arangodb::SingleCollectionTransaction trx(arangodb::transaction::StandaloneContext::Create(vocbase),
|
||||
*collection,
|
||||
arangodb::AccessMode::Type::WRITE);
|
||||
EXPECT_TRUE((trx.begin().ok()));
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto res = trx.insert(collection->name(), itr.value(), options);
|
||||
EXPECT_TRUE((res.ok()));
|
||||
insertedDocs.emplace_back(res.slice().get("new"));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((trx.commit().ok()));
|
||||
}
|
||||
|
||||
// create view
|
||||
{
|
||||
auto createJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"name\": \"testView\", \"type\": \"arangosearch\" }");
|
||||
auto logicalView = vocbase.createView(createJson->slice());
|
||||
ASSERT_TRUE((false == !logicalView));
|
||||
|
||||
view = logicalView.get();
|
||||
auto* impl = dynamic_cast<arangodb::iresearch::IResearchView*>(view);
|
||||
ASSERT_TRUE((false == !impl));
|
||||
|
||||
auto updateJson = arangodb::velocypack::Parser::fromJson(
|
||||
"{ \"links\": {"
|
||||
"\"testCollection0\": { \"analyzers\": [ \"test_analyzer\", "
|
||||
"\"::test_analyzer\", \"identity\" ], \"includeAllFields\": true, "
|
||||
"\"trackListPositions\": true },"
|
||||
"\"testCollection1\": { \"analyzers\": [ \"test_analyzer\", "
|
||||
"\"_system::test_analyzer\", \"identity\" ], \"includeAllFields\": "
|
||||
"true }"
|
||||
"}}");
|
||||
EXPECT_TRUE((impl->properties(updateJson->slice(), true).ok()));
|
||||
std::set<TRI_voc_cid_t> cids;
|
||||
impl->visitCollections([&cids](TRI_voc_cid_t cid) -> bool {
|
||||
cids.emplace(cid);
|
||||
return true;
|
||||
});
|
||||
EXPECT_TRUE((2 == cids.size()));
|
||||
EXPECT_TRUE(
|
||||
(arangodb::tests::executeQuery(vocbase,
|
||||
"FOR d IN testView SEARCH 1 ==1 OPTIONS "
|
||||
"{ waitForSync: true } RETURN d")
|
||||
.result.ok())); // commit
|
||||
}
|
||||
|
||||
// same as term query
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice()
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', 1) RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
|
||||
// same as disjunction
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice(),
|
||||
insertedDocs[7].slice()
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, 1) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
|
||||
// same as disjunction
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice(),
|
||||
insertedDocs[7].slice()
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, 1.0) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
|
||||
// non-deterministic conditions count type
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, CEIL(RAND())) SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid conditions count type
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, '1') SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid conditions count type
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, {}) SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid conditions count type
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, []) SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid conditions count type
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, null) SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid conditions count type
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, true) SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// missing conditions count argument
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1) SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// missing conditions count argument
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A') SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH));
|
||||
}
|
||||
|
||||
// missing arguments
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH() SORT d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH));
|
||||
}
|
||||
|
||||
// FIXME currently optimizer tries to evaluate MIN_MATCH function
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH MIN_MATCH(1==1, 2==2, 3==3, 2) "
|
||||
"SORT d.seq "
|
||||
"RETURN d";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
// same as disjunction
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice(),
|
||||
insertedDocs[7].slice()
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, 1) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
|
||||
// same as conjunction
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice()
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 0, 2) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
|
||||
// unreachable condition (conjunction)
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, 2) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
ASSERT_TRUE(0 == slice.length());
|
||||
}
|
||||
|
||||
// unreachable condition
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, 3) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
ASSERT_TRUE(0 == slice.length());
|
||||
}
|
||||
|
||||
// 2 conditions
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice(),
|
||||
insertedDocs[7].slice()
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, d.value >= 100 || d.value <= 150, 2) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
|
||||
// 2 conditions
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice(),
|
||||
insertedDocs[7].slice()
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, d.seq == 'xxx', d.value >= 100 || d.value <= 150, 2) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
|
||||
// 2 conditions
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice(),
|
||||
insertedDocs[7].slice(),
|
||||
insertedDocs[8].slice(),
|
||||
insertedDocs[9].slice(),
|
||||
insertedDocs[10].slice(),
|
||||
insertedDocs[11].slice(),
|
||||
insertedDocs[12].slice(),
|
||||
insertedDocs[13].slice(),
|
||||
insertedDocs[14].slice(),
|
||||
insertedDocs[15].slice(),
|
||||
insertedDocs[16].slice(),
|
||||
insertedDocs[17].slice(),
|
||||
insertedDocs[18].slice(),
|
||||
insertedDocs[19].slice(),
|
||||
insertedDocs[20].slice(),
|
||||
insertedDocs[21].slice(),
|
||||
insertedDocs[22].slice(),
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, d.same == 'xyz', d.value >= 100 || d.value <= 150, 2) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
|
||||
// 3 conditions
|
||||
{
|
||||
std::vector<arangodb::velocypack::Slice> expected = {
|
||||
insertedDocs[6].slice(),
|
||||
insertedDocs[7].slice()
|
||||
};
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH MIN_MATCH(d.name == 'A', d.seq == 1, d.same == 'xyz', d.value >= 100 || d.value <= 150, 3) SORT d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.ok());
|
||||
auto slice = result.data->slice();
|
||||
EXPECT_TRUE(slice.isArray());
|
||||
size_t i = 0;
|
||||
|
||||
for (arangodb::velocypack::ArrayIterator itr(slice); itr.valid(); ++itr) {
|
||||
auto const resolved = itr.value().resolveExternals();
|
||||
EXPECT_TRUE((i < expected.size()));
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(expected[i++],
|
||||
resolved, true)));
|
||||
}
|
||||
|
||||
EXPECT_TRUE((i == expected.size()));
|
||||
}
|
||||
}
|
|
@ -452,9 +452,7 @@ TEST_F(IResearchQueryOptionsTest, Collections) {
|
|||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH d.name == 'A'"
|
||||
" OPTIONS { collections : [ " +
|
||||
std::to_string(logicalCollection2->id()) +
|
||||
" ] }"
|
||||
" OPTIONS { collections : [ " + std::to_string(logicalCollection2->id()) + " ] }"
|
||||
" RETURN d";
|
||||
|
||||
EXPECT_TRUE(arangodb::tests::assertRules(
|
||||
|
@ -530,9 +528,7 @@ TEST_F(IResearchQueryOptionsTest, Collections) {
|
|||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH d.name == 'A'"
|
||||
" OPTIONS { collections : [ '" +
|
||||
std::to_string(logicalCollection2->id()) +
|
||||
"', 'collection_1' ] }"
|
||||
" OPTIONS { collections : [ '" + std::to_string(logicalCollection2->id()) + "', 'collection_1' ] }"
|
||||
" SORT d._id"
|
||||
" RETURN d";
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, [ ]) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (empty-array) via []
|
||||
|
@ -442,7 +442,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], [ ]) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (array)
|
||||
|
@ -451,7 +451,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, [ 1, \"abc\" ]) SORT BM25(d) "
|
||||
"ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (array) via []
|
||||
|
@ -460,7 +460,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], [ 1, \"abc\" ]) SORT "
|
||||
"BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (boolean)
|
||||
|
@ -469,7 +469,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, true) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (boolean) via []
|
||||
|
@ -478,7 +478,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], false) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (null)
|
||||
|
@ -487,7 +487,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, null) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (null) via []
|
||||
|
@ -496,7 +496,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], null) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (numeric)
|
||||
|
@ -505,7 +505,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, 3.14) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (numeric) via []
|
||||
|
@ -514,7 +514,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], 1234) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (object)
|
||||
|
@ -523,7 +523,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, { \"a\": 7, \"b\": \"c\" }) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (object) via []
|
||||
|
@ -532,7 +532,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], { \"a\": 7, \"b\": \"c\" "
|
||||
"}) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test missing value
|
||||
|
@ -559,7 +559,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d.duplicated, 'z'), [ 1, "
|
||||
"\"abc\" ]) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (array) via []
|
||||
|
@ -568,7 +568,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d['duplicated'], 'z'), [ 1, "
|
||||
"\"abc\" ]) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (boolean)
|
||||
|
@ -577,7 +577,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d.duplicated, 'z'), true) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (boolean) via []
|
||||
|
@ -586,7 +586,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d['duplicated'], 'z'), "
|
||||
"false) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (null)
|
||||
|
@ -595,7 +595,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d.duplicated, 'z'), null) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (null) via []
|
||||
|
@ -604,7 +604,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d['duplicated'], 'z'), null) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (numeric)
|
||||
|
@ -613,7 +613,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d.duplicated, 'z'), 3.14) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (numeric) via []
|
||||
|
@ -622,7 +622,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d['duplicated'], 'z'), 1234) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (object)
|
||||
|
@ -631,7 +631,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d.duplicated, 'z'), { \"a\": "
|
||||
"7, \"b\": \"c\" }) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (object) via []
|
||||
|
@ -641,7 +641,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
"FOR d IN testView SEARCH analyzer(PHRASE(d['duplicated'], 'z'), { "
|
||||
"\"a\": 7, \"b\": \"c\" }) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq "
|
||||
"RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test undefined analyzer
|
||||
|
@ -650,7 +650,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d.duplicated, 'z'), "
|
||||
"'invalid_analyzer') SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test undefined analyzer via []
|
||||
|
@ -659,7 +659,7 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d['duplicated'], 'z'), "
|
||||
"'invalid_analyzer') SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// can't access to local analyzer in other database
|
||||
|
@ -669,7 +669,17 @@ TEST_F(IResearchQueryPhraseTest, SysVocbase) {
|
|||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d.duplicated, 'z'), "
|
||||
"'testVocbase::test_analyzer') SORT BM25(d) ASC, TFIDF(d) DESC, d.seq "
|
||||
"RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// FIXME currently optimizer tries to evaluate ANALYZER function
|
||||
{
|
||||
auto result = arangodb::tests::executeQuery(
|
||||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(1==1, 'test_analyzer') && ANALYZER(PHRASE(d.duplicated, 'z'), "
|
||||
"'test_analyzer') SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_FALSE(result.result.ok());
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
// test custom analyzer
|
||||
|
@ -1340,7 +1350,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, [ ]) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (empty-array) via []
|
||||
|
@ -1349,7 +1359,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], [ ]) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (array)
|
||||
|
@ -1358,7 +1368,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, [ 1, \"abc\" ]) SORT BM25(d) "
|
||||
"ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (array) via []
|
||||
|
@ -1367,7 +1377,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], [ 1, \"abc\" ]) SORT "
|
||||
"BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (boolean)
|
||||
|
@ -1376,7 +1386,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, true) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (boolean) via []
|
||||
|
@ -1385,7 +1395,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], false) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (null)
|
||||
|
@ -1394,7 +1404,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, null) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (null) via []
|
||||
|
@ -1403,7 +1413,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], null) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (numeric)
|
||||
|
@ -1412,7 +1422,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, 3.14) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (numeric) via []
|
||||
|
@ -1421,7 +1431,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], 1234) SORT BM25(d) ASC, "
|
||||
"TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (object)
|
||||
|
@ -1430,7 +1440,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d.value, { \"a\": 7, \"b\": \"c\" }) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid input type (object) via []
|
||||
|
@ -1439,7 +1449,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH PHRASE(d['value'], { \"a\": 7, \"b\": \"c\" "
|
||||
"}) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test missing value
|
||||
|
@ -1466,7 +1476,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d.duplicated, 'z'), [ 1, "
|
||||
"\"abc\" ]) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (array) via []
|
||||
|
@ -1475,7 +1485,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d['duplicated'], 'z'), [ 1, "
|
||||
"\"abc\" ]) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (boolean)
|
||||
|
@ -1484,7 +1494,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d.duplicated, 'z'), true) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (boolean) via []
|
||||
|
@ -1493,7 +1503,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d['duplicated'], 'z'), "
|
||||
"false) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (null)
|
||||
|
@ -1502,7 +1512,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d.duplicated, 'z'), null) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (null) via []
|
||||
|
@ -1511,7 +1521,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d['duplicated'], 'z'), null) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (numeric)
|
||||
|
@ -1520,7 +1530,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d.duplicated, 'z'), 3.14) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (numeric) via []
|
||||
|
@ -1529,7 +1539,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d['duplicated'], 'z'), 1234) "
|
||||
"SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (object)
|
||||
|
@ -1538,7 +1548,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d.duplicated, 'z'), { \"a\": "
|
||||
"7, \"b\": \"c\" }) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test invalid analyzer type (object) via []
|
||||
|
@ -1548,7 +1558,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
"FOR d IN testView SEARCH analyzer(PHRASE(d['duplicated'], 'z'), { "
|
||||
"\"a\": 7, \"b\": \"c\" }) SORT BM25(d) ASC, TFIDF(d) DESC, d.seq "
|
||||
"RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test undefined analyzer
|
||||
|
@ -1557,7 +1567,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH analyzer(PHRASE(d.duplicated, 'z'), "
|
||||
"'invalid_analyzer') SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test undefined analyzer via []
|
||||
|
@ -1566,7 +1576,7 @@ TEST_F(IResearchQueryPhraseTest, test) {
|
|||
vocbase,
|
||||
"FOR d IN testView SEARCH ANALYZER(PHRASE(d['duplicated'], 'z'), "
|
||||
"'invalid_analyzer') SORT BM25(d) ASC, TFIDF(d) DESC, d.seq RETURN d");
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_QUERY_PARSE));
|
||||
ASSERT_TRUE(result.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// test custom analyzer (local)
|
||||
|
|
|
@ -383,6 +383,138 @@ TEST_F(IResearchQueryScorerTest, test) {
|
|||
.result.ok())); // commit
|
||||
}
|
||||
|
||||
// wrong number of arguments
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(d.name == 'A') "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH));
|
||||
}
|
||||
|
||||
// invalid argument
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(d.name == 'A', {}) "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid argument
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(d.name == 'A', []) "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid argument
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(d.name == 'A', true) "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid argument
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(d.name == 'A', null) "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// invalid argument
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(d.name == 'A', '42') "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// non-deterministic argument
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(d.name == 'A', RAND()) "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_BAD_PARAMETER));
|
||||
}
|
||||
|
||||
// FIXME currently optimizer tries to evaluate BOOST function
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(1==1, 42) "
|
||||
"LIMIT 1 "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_FALSE(queryResult.result.ok());
|
||||
ASSERT_TRUE(queryResult.result.is(TRI_ERROR_NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
{
|
||||
std::string const query =
|
||||
"FOR d IN testView SEARCH BOOST(d.name == 'A', 42) "
|
||||
"RETURN { d, score: BOOSTSCORER(d) }";
|
||||
|
||||
EXPECT_TRUE(arangodb::tests::assertRules(vocbase, query, {
|
||||
arangodb::aql::OptimizerRule::handleArangoSearchViewsRule,
|
||||
}));
|
||||
|
||||
std::map<float, arangodb::velocypack::Slice> expectedDocs{
|
||||
{42.f, arangodb::velocypack::Slice(insertedDocsView[0].vpack())}
|
||||
};
|
||||
|
||||
auto queryResult = arangodb::tests::executeQuery(vocbase, query);
|
||||
ASSERT_TRUE(queryResult.result.ok());
|
||||
|
||||
auto result = queryResult.data->slice();
|
||||
EXPECT_TRUE(result.isArray());
|
||||
|
||||
arangodb::velocypack::ArrayIterator resultIt(result);
|
||||
ASSERT_TRUE(expectedDocs.size() == resultIt.size());
|
||||
|
||||
// Check documents
|
||||
for (; resultIt.valid(); resultIt.next()) {
|
||||
auto const actualValue = resultIt.value();
|
||||
|
||||
auto actualScoreSlice = actualValue.get("score");
|
||||
ASSERT_TRUE(actualScoreSlice.isNumber());
|
||||
auto const actualScore = actualScoreSlice.getNumber<float>();
|
||||
auto expectedValue = expectedDocs.find(actualScore);
|
||||
ASSERT_TRUE(expectedValue != expectedDocs.end());
|
||||
|
||||
auto const actualDoc = actualValue.get("d");
|
||||
auto const resolved = actualDoc.resolveExternals();
|
||||
|
||||
EXPECT_TRUE((0 == arangodb::basics::VelocyPackHelper::compare(
|
||||
arangodb::velocypack::Slice(expectedValue->second),
|
||||
resolved, true)));
|
||||
expectedDocs.erase(expectedValue);
|
||||
}
|
||||
EXPECT_TRUE(expectedDocs.empty());
|
||||
}
|
||||
|
||||
{
|
||||
std::string const query =
|
||||
"LET arr = [0,1] "
|
||||
|
|
Loading…
Reference in New Issue