mirror of https://gitee.com/bigwinds/arangodb
Bug fix 3.5/issue 10078 (#10082)
* fixed issue #10078: FULLTEXT with sort on same field not working * added test * simplify the implementation
This commit is contained in:
parent
7b427a549d
commit
451bd6e85d
|
@ -1,6 +1,8 @@
|
||||||
v3.5.1 (XXXX-XX-XX)
|
v3.5.1 (XXXX-XX-XX)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Fixed issue #10078: FULLTEXT with sort on same field not working.
|
||||||
|
|
||||||
* Fixed issue #10062: AQL: could not extract custom attribute.
|
* Fixed issue #10062: AQL: could not extract custom attribute.
|
||||||
|
|
||||||
* Fix compilation issue with clang 10.
|
* Fix compilation issue with clang 10.
|
||||||
|
|
|
@ -67,7 +67,7 @@ class RocksDBFulltextIndex final : public RocksDBIndex {
|
||||||
|
|
||||||
bool canBeDropped() const override { return true; }
|
bool canBeDropped() const override { return true; }
|
||||||
|
|
||||||
bool isSorted() const override { return true; }
|
bool isSorted() const override { return false; }
|
||||||
|
|
||||||
bool hasSelectivityEstimate() const override { return false; }
|
bool hasSelectivityEstimate() const override { return false; }
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,13 @@ var findReferencedNodes = helper.findReferencedNodes;
|
||||||
var getQueryMultiplePlansAndExecutions = helper.getQueryMultiplePlansAndExecutions;
|
var getQueryMultiplePlansAndExecutions = helper.getQueryMultiplePlansAndExecutions;
|
||||||
var removeAlwaysOnClusterRules = helper.removeAlwaysOnClusterRules;
|
var removeAlwaysOnClusterRules = helper.removeAlwaysOnClusterRules;
|
||||||
|
|
||||||
|
const ruleName = "use-index-for-sort";
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief test suite
|
/// @brief test suite
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function optimizerRuleTestSuite() {
|
function optimizerRuleTestSuite() {
|
||||||
const ruleName = "use-index-for-sort";
|
|
||||||
const colName = "UnitTestsUseIndexForSort";
|
const colName = "UnitTestsUseIndexForSort";
|
||||||
let c;
|
let c;
|
||||||
|
|
||||||
|
@ -195,6 +196,48 @@ function optimizerRuleTestSuite() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function optimizerRuleWithOtherIndexTypesTestSuite() {
|
||||||
|
const cn = "UnitTestsCollection";
|
||||||
|
|
||||||
|
return {
|
||||||
|
setUp : function () {
|
||||||
|
internal.db._drop(cn);
|
||||||
|
internal.db._create(cn, { numberOfShards: 3 });
|
||||||
|
},
|
||||||
|
|
||||||
|
tearDown : function () {
|
||||||
|
internal.db._drop(cn);
|
||||||
|
},
|
||||||
|
|
||||||
|
testFulltextAscending : function () {
|
||||||
|
internal.db[cn].ensureIndex({ type: "fulltext", fields: ["name"] });
|
||||||
|
internal.db[cn].insert([ { name: "Agatha" }, { name: "Agathe" }, { name: "Aardvark" }, { name: "Aaron" }, { name: "Astrid" }, { name: "Ana" }, { name: "Anna" }, { name: "Anne" }, { name: "Ali" } ]);
|
||||||
|
|
||||||
|
let query = `FOR doc IN FULLTEXT(${cn}, 'name', 'prefix:a') SORT doc.name RETURN doc.name`;
|
||||||
|
|
||||||
|
let rules = AQL_EXPLAIN(query).plan.rules;
|
||||||
|
assertEqual(-1, rules.indexOf(ruleName));
|
||||||
|
|
||||||
|
let results = AQL_EXECUTE(query).json;
|
||||||
|
assertEqual([ "Aardvark", "Aaron", "Agatha", "Agathe", "Ali", "Ana", "Anna", "Anne", "Astrid" ], results);
|
||||||
|
},
|
||||||
|
|
||||||
|
testFulltextDescending : function () {
|
||||||
|
internal.db[cn].ensureIndex({ type: "fulltext", fields: ["name"] });
|
||||||
|
internal.db[cn].insert([ { name: "Agatha" }, { name: "Agathe" }, { name: "Aardvark" }, { name: "Aaron" }, { name: "Astrid" }, { name: "Ana" }, { name: "Anna" }, { name: "Anne" }, { name: "Ali" } ]);
|
||||||
|
|
||||||
|
let query = `FOR doc IN FULLTEXT(${cn}, 'name', 'prefix:a') SORT doc.name DESC RETURN doc.name`;
|
||||||
|
|
||||||
|
let rules = AQL_EXPLAIN(query).plan.rules;
|
||||||
|
assertEqual(-1, rules.indexOf(ruleName));
|
||||||
|
|
||||||
|
let results = AQL_EXECUTE(query).json;
|
||||||
|
assertEqual([ "Astrid", "Anne", "Anna", "Ana", "Ali", "Agathe", "Agatha", "Aaron", "Aardvark" ], results);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
jsunity.run(optimizerRuleTestSuite);
|
jsunity.run(optimizerRuleTestSuite);
|
||||||
|
jsunity.run(optimizerRuleWithOtherIndexTypesTestSuite);
|
||||||
|
|
||||||
return jsunity.done();
|
return jsunity.done();
|
||||||
|
|
|
@ -38,12 +38,13 @@ var findReferencedNodes = helper.findReferencedNodes;
|
||||||
var getQueryMultiplePlansAndExecutions = helper.getQueryMultiplePlansAndExecutions;
|
var getQueryMultiplePlansAndExecutions = helper.getQueryMultiplePlansAndExecutions;
|
||||||
var removeAlwaysOnClusterRules = helper.removeAlwaysOnClusterRules;
|
var removeAlwaysOnClusterRules = helper.removeAlwaysOnClusterRules;
|
||||||
|
|
||||||
|
const ruleName = "use-index-for-sort";
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief test suite
|
/// @brief test suite
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function optimizerRuleTestSuite() {
|
function optimizerRuleTestSuite() {
|
||||||
var ruleName = "use-index-for-sort";
|
|
||||||
var secondRuleName = "use-indexes";
|
var secondRuleName = "use-indexes";
|
||||||
var removeCalculationNodes = "remove-unnecessary-calculations-2";
|
var removeCalculationNodes = "remove-unnecessary-calculations-2";
|
||||||
var colName = "UnitTestsAqlOptimizer" + ruleName.replace(/-/g, "_");
|
var colName = "UnitTestsAqlOptimizer" + ruleName.replace(/-/g, "_");
|
||||||
|
|
Loading…
Reference in New Issue