MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / extract_text_search_predicate

Method extract_text_search_predicate

graphlite/src/plan/optimizer.rs:627–718  ·  view source on GitHub ↗

ROADMAP v0.6.0 - Full-text search index optimization

(
        &self,
        expr: &Expression,
    )

Source from the content-addressed store, hash-verified

625 /// Returns (variable, query, field, min_score) if this is a text search predicate
626 #[allow(dead_code)] // ROADMAP v0.6.0 - Full-text search index optimization
627 fn extract_text_search_predicate(
628 &self,
629 expr: &Expression,
630 ) -> Option<(String, String, String, f64)> {
631 match expr {
632 // Match: TEXT_SEARCH(doc.content, 'query') - standalone boolean predicate (Phase 4)
633 Expression::FunctionCall(func)
634 if func.name.eq_ignore_ascii_case("text_search") && func.arguments.len() >= 2 =>
635 {
636 // Extract field from first argument (property access)
637 if let (Some((variable, field)), Some(query)) = (
638 self.extract_property_access(&func.arguments[0]),
639 self.extract_string_literal(&func.arguments[1]),
640 ) {
641 // Check for optional min_score as 3rd argument
642 let min_score = if func.arguments.len() >= 3 {
643 self.extract_number_literal(&func.arguments[2])
644 .unwrap_or(0.0)
645 } else {
646 0.0 // No minimum score filter
647 };
648 return Some((variable, query, field, min_score));
649 }
650 }
651
652 // Match: text_search(doc.content, 'query') > 5.0 - with explicit score threshold
653 Expression::Binary(binary)
654 if matches!(
655 binary.operator,
656 Operator::GreaterThan | Operator::GreaterEqual
657 ) =>
658 {
659 // Check if left side is text_search() function call
660 if let Expression::FunctionCall(func) = &*binary.left {
661 if func.name.eq_ignore_ascii_case("text_search") && func.arguments.len() >= 2 {
662 // Extract field from first argument (property access)
663 if let (Some((variable, field)), Some(query), Some(min_score)) = (
664 self.extract_property_access(&func.arguments[0]),
665 self.extract_string_literal(&func.arguments[1]),
666 self.extract_number_literal(&binary.right),
667 ) {
668 return Some((variable, query, field, min_score));
669 }
670 }
671 }
672 }
673
674 // Match: fuzzy_match(person.name, 'query', 2) > 0.7
675 Expression::Binary(binary)
676 if matches!(
677 binary.operator,
678 Operator::GreaterThan | Operator::GreaterEqual
679 ) =>
680 {
681 if let Expression::FunctionCall(func) = &*binary.left {
682 if func.name.eq_ignore_ascii_case("fuzzy_match") && func.arguments.len() >= 2 {
683 if let (Some((variable, field)), Some(query), Some(min_score)) = (
684 self.extract_property_access(&func.arguments[0]),

Callers

nothing calls this directly

Calls 4

lenMethod · 0.45

Tested by

no test coverage detected