8000 Backport Bug fix/fix devsup 753 (#14373) · arangodb/arangodb@dfc19bd · GitHub
[go: up one dir, main page]

Skip to content

Commit dfc19bd

Browse files
committed
Backport Bug fix/fix devsup 753 (#14373)
1 parent 04b20f1 commit dfc19bd

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

3rdParty/iresearch/core/search/disjunction.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,9 @@ class disjunction final
766766
virtual void visit(void* ctx, bool (*visitor)(void*, Adapter&)) override {
767767
assert(ctx);
768768
assert(visitor);
769+
if (heap_.empty()) {
770+
return;
771+
}
769772
hitch_all_iterators();
770773
auto& lead = itrs_[heap_.back()];
771774
auto cont = visitor(ctx, lead);
@@ -908,6 +911,7 @@ class disjunction final
908911
}
909912

910913
std::pair<heap_iterator, heap_iterator> hitch_all_iterators() {
914+
assert(!heap_.empty());
911915
// hitch all iterators in head to the lead (current doc_)
912916
auto begin = heap_.begin(), end = heap_.end()-1;
913917

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
v3.8.0-rc.2 (2021-06-07)
22
------------------------
33

4+
* Fix DEVSUP-753: now it is safe to call visit on exhausted disjunction
5+
iterator.
6+
47
* Added check to utils/generateAllMetricsDocumentation.py to check that the file
58
name and the value of the name attribute are the same in the metrics
69
documentation snippets. Correct a few such names.

tests/js/common/aql/aql-view-arangosearch-noncluster.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,55 @@ function iResearchAqlTestSuite () {
25672567
db._dropView(queryView);
25682568
analyzers.remove(queryAnalyzer, true);
25692569
}
2570+
},
2571+
2572+
testDisjunctionVisit : function() {
2573+
let queryColl = "DisjunctionCollection";
2574+
let queryView = "DisjunctionView";
2575+
try {
2576+
db._drop(queryColl);
2577+
db._dropView(queryView);
2578+
let coll = db._create(queryColl);
2579+
let view = db._createView(queryView, "arangosearch", {
2580+
links: {
2581+
[queryColl] : {
2582+
fields: {
2583+
value: { analyzers:['identity', 'text_en'] }
2584+
}
2585+
}
2586+
}
2587+
});
2588+
let documents = [
2589+
{"value":"test"},
2590+
// these docs will make STARTS_WITH more "costly" than PHRASE and conjunction will use PHRASE as lead!
2591+
{"value":"test1234"},
2592+
{"value":"test21321312312"},
2593+
{"value":"test213213123122"},
2594+
{"value":"test2132131231222"},
2595+
{"value":"test21321312312222"},
2596+
{"value":"test2132131231222322"},
2597+
{"value":"test2132131231231231222322"},
2598+
// this will make PHRASE iterator not use small_disjunction (more than 5 candidates for LEVENSHTEIN)
2599+
{"value":"rest"},
2600+
{"value":"arest"},
2601+
{"value":"brest"},
2602+
{"value":"zest"},
2603+
{"value":"qest"}];
2604+
db[queryColl].save(documents);
2605+
let res = db._query("FOR d IN " + queryView +" SEARCH "
2606+
+ " (ANALYZER(PHRASE(d.value, {LEVENSHTEIN_MATCH : ['test', 2, true]}), 'text_en') "
2607+
+ " && ANALYZER(STARTS_WITH(d.value, 'test'),'text_en')) OR "
2608+
+ " BOOST(PHRASE(d.value, 'test144', 'identity'), 10) "
2609+
+ " OPTIONS {waitForSync:true} SORT BM25(d) DESC LIMIT 20 "
2610+
+ " RETURN {'Score':BM25(d), 'Id' : d.value, 'Entity' : d }").toArray();
2611+
assertEqual(1, res.length);
2612+
2613+
} finally {
2614+
db._drop(queryColl);
2615+
db._dropView(queryView);
2616+
}
25702617
}
2618+
25712619
};
25722620
}
25732621

0 commit comments

Comments
 (0)
0