8000 Bug fix/fix devsup 753 by Dronplane · Pull Request #14373 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Bug fix/fix devsup 753 #14373

New issue

Have a question about this project? Sign up for 8000 a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 3rdParty/iresearch/core/search/disjunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,9 @@ class disjunction final
virtual void visit(void* ctx, bool (*visitor)(void*, Adapter&)) override {
assert(ctx);
assert(visitor);
if (heap_.empty()) {
return;
}
hitch_all_iterators();
auto& lead = itrs_[heap_.back()];
auto cont = visitor(ctx, lead);
Expand Down Expand Up @@ -908,6 +911,7 @@ class disjunction final
}

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

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
devel
-----
* Fix DEVSUP-753: now it is safe to call visit on exhausted disjunction
iterator.

* Slightly improve specific warning messages for better readability.

Expand Down
48 changes: 48 additions & 0 deletions tests/js/common/aql/aql-view-arangosearch-noncluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,55 @@ function iResearchAqlTestSuite () {
db._dropView(queryView);
analyzers.remove(queryAnalyzer, true);
}
},

testDisjunctionVisit : function() {
let queryColl = "DisjunctionCollection";
let queryView = "DisjunctionView";
try {
db._drop(queryColl);
db._dropView(queryView);
let coll = db._create(queryColl);
let view = db._createView(queryView, "arangosearch", {
links: {
[queryColl] : {
fields: {
value: { analyzers:['identity', 'text_en'] }
}
}
}
});
let documents = [
{"value":"test"},
// these docs will make STARTS_WITH more "costly" than PHRASE and conjunction will use PHRASE as lead!
{"value":"test1234"},
{"value":"test21321312312"},
{"value":"test213213123122"},
{"value":"test2132131231222"},
{"value":"test21321312312222"},
{"value":"test2132131231222322"},
{"value":"test2132131231231231222322"},
// this will make PHRASE iterator not use small_disjunction (more than 5 candidates for LEVENSHTEIN)
{"value":"rest"},
{"value":"arest"},
{"value":"brest"},
{"value":"zest"},
{"value":"qest"}];
db[queryColl].save(documents);
let res = db._query("FOR d IN " + queryView +" SEARCH "
+ " (ANALYZER(PHRASE(d.value, {LEVENSHTEIN_MATCH : ['test', 2, true]}), 'text_en') "
+ " && ANALYZER(STARTS_WITH(d.value, 'test'),'text_en')) OR "
+ " BOOST(PHRASE(d.value, 'test144', 'identity'), 10) "
+ " OPTIONS {waitForSync:true} SORT BM25(d) DESC LIMIT 20 "
+ " RETURN {'Score':BM25(d), 'Id' : d.value, 'Entity' : d }").toArray();
assertEqual(1, res.length);

} finally {
db._drop(queryColl);
db._dropView(queryView);
}
}

};
}

Expand Down
0