From 5ad9423f16c685fb99be01662534f3b27d3cef14 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 8 Jun 2017 13:35:00 +0200 Subject: [PATCH] unify index struct return values in cluster and non-cluster for fulltext and geo indexes (#2534) --- ...x-geo-spec-mmfiles.rb => api-index-geo-spec.rb} | 0 arangod/MMFiles/MMFilesFulltextIndex.cpp | 2 -- arangod/MMFiles/MMFilesIndexFactory.cpp | 14 +++++++++++--- arangod/RocksDBEngine/RocksDBIndexFactory.cpp | 14 +++++++++++--- 4 files changed, 22 insertions(+), 8 deletions(-) rename UnitTests/HttpInterface/{api-index-geo-spec-mmfiles.rb => api-index-geo-spec.rb} (100%) diff --git a/UnitTests/HttpInterface/api-index-geo-spec-mmfiles.rb b/UnitTests/HttpInterface/api-index-geo-spec.rb similarity index 100% rename from UnitTests/HttpInterface/api-index-geo-spec-mmfiles.rb rename to UnitTests/HttpInterface/api-index-geo-spec.rb diff --git a/arangod/MMFiles/MMFilesFulltextIndex.cpp b/arangod/MMFiles/MMFilesFulltextIndex.cpp index 05f9a1f7f0..6bf9bfca3a 100644 --- a/arangod/MMFiles/MMFilesFulltextIndex.cpp +++ b/arangod/MMFiles/MMFilesFulltextIndex.cpp @@ -114,8 +114,6 @@ MMFilesFulltextIndex::MMFilesFulltextIndex(TRI_idx_iid_t iid, } } - - MMFilesFulltextIndex::~MMFilesFulltextIndex() { if (_fulltextIndex != nullptr) { LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "destroying fulltext index"; diff --git a/arangod/MMFiles/MMFilesIndexFactory.cpp b/arangod/MMFiles/MMFilesIndexFactory.cpp index c851e2f3e8..e677444b04 100644 --- a/arangod/MMFiles/MMFilesIndexFactory.cpp +++ b/arangod/MMFiles/MMFilesIndexFactory.cpp @@ -170,9 +170,13 @@ static int EnhanceJsonIndexPersistent(VPackSlice const definition, static void ProcessIndexGeoJsonFlag(VPackSlice const definition, VPackBuilder& builder) { - bool geoJson = - basics::VelocyPackHelper::getBooleanValue(definition, "geoJson", false); - builder.add("geoJson", VPackValue(geoJson)); + VPackSlice fieldsSlice = definition.get("fields"); + if (fieldsSlice.isArray() && fieldsSlice.length() == 1) { + // only add geoJson for indexes with a single field (with needs to be an array) + bool geoJson = + basics::VelocyPackHelper::getBooleanValue(definition, "geoJson", false); + builder.add("geoJson", VPackValue(geoJson)); + } } //////////////////////////////////////////////////////////////////////////////// @@ -221,6 +225,10 @@ static int EnhanceJsonIndexFulltext(VPackSlice const definition, VPackBuilder& builder, bool create) { int res = ProcessIndexFields(definition, builder, 1, create); if (res == TRI_ERROR_NO_ERROR) { + // hard-coded defaults + builder.add("sparse", VPackValue(true)); + builder.add("unique", VPackValue(false)); + // handle "minLength" attribute int minWordLength = TRI_FULLTEXT_MIN_WORD_LENGTH_DEFAULT; VPackSlice minLength = definition.get("minLength"); diff --git a/arangod/RocksDBEngine/RocksDBIndexFactory.cpp b/arangod/RocksDBEngine/RocksDBIndexFactory.cpp index 4018caefc8..d8099f9a05 100644 --- a/arangod/RocksDBEngine/RocksDBIndexFactory.cpp +++ b/arangod/RocksDBEngine/RocksDBIndexFactory.cpp @@ -170,9 +170,13 @@ static int EnhanceJsonIndexPersistent(VPackSlice const definition, static void ProcessIndexGeoJsonFlag(VPackSlice const definition, VPackBuilder& builder) { - bool geoJson = - basics::VelocyPackHelper::getBooleanValue(definition, "geoJson", false); - builder.add("geoJson", VPackValue(geoJson)); + VPackSlice fieldsSlice = definition.get("fields"); + if (fieldsSlice.isArray() && fieldsSlice.length() == 1) { + // only add geoJson for indexes with a single field (with needs to be an array) + bool geoJson = + basics::VelocyPackHelper::getBooleanValue(definition, "geoJson", false); + builder.add("geoJson", VPackValue(geoJson)); + } } //////////////////////////////////////////////////////////////////////////////// @@ -222,6 +226,10 @@ static int EnhanceJsonIndexFulltext(VPackSlice const definition, VPackBuilder& builder, bool create) { int res = ProcessIndexFields(definition, builder, 1, create); if (res == TRI_ERROR_NO_ERROR) { + // hard-coded defaults + builder.add("sparse", VPackValue(true)); + builder.add("unique", VPackValue(false)); + // handle "minLength" attribute int minWordLength = TRI_FULLTEXT_MIN_WORD_LENGTH_DEFAULT; VPackSlice minLength = definition.get("minLength");