mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-31 02:40:01 +00:00
Fix bugs in query graph's "remove word" and "cheapest paths" algos
This commit is contained in:
@ -192,18 +192,14 @@ impl QueryGraph {
|
||||
}
|
||||
pub fn remove_words_at_position(&mut self, position: i8) {
|
||||
let mut nodes_to_remove_keeping_edges = vec![];
|
||||
let mut nodes_to_remove = vec![];
|
||||
for (node_idx, node) in self.nodes.iter().enumerate() {
|
||||
let node_idx = node_idx as u32;
|
||||
let QueryNode::Term(LocatedQueryTerm { value: _, positions }) = node else { continue };
|
||||
if positions.contains(&position) {
|
||||
if positions.start() == &position {
|
||||
nodes_to_remove_keeping_edges.push(node_idx)
|
||||
} else if positions.contains(&position) {
|
||||
nodes_to_remove.push(node_idx)
|
||||
}
|
||||
}
|
||||
|
||||
self.remove_nodes(&nodes_to_remove);
|
||||
self.remove_nodes_keep_edges(&nodes_to_remove_keeping_edges);
|
||||
|
||||
self.simplify();
|
||||
|
Reference in New Issue
Block a user