Module: Card::Query::Value::FullTextValue

Included in:
Card::Query::Value
Defined in:
lib/card/query/card_query/full_text_matching.rb

Instance Method Summary collapse

Instance Method Details

#fulltext_fieldsObject



56
57
58
# File 'lib/card/query/card_query/full_text_matching.rb', line 56

def fulltext_fields
  %i[search_content name].map { |fld| "#{@query.table_alias}.#{fld}" }.join ", "
end

#fulltext_match_term?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/card/query/card_query/full_text_matching.rb', line 52

def fulltext_match_term?
  match_prefix.match? ":"
end

#fulltext_modeObject



60
61
62
# File 'lib/card/query/card_query/full_text_matching.rb', line 60

def fulltext_mode
  match_prefix == "::" ? "IN BOOLEAN MODE" : ""
end

#match_sql(_field) ⇒ Object



47
48
49
50
# File 'lib/card/query/card_query/full_text_matching.rb', line 47

def match_sql _field
  return super unless fulltext_match_term?
  "MATCH (#{fulltext_fields}) AGAINST (#{quote match_term} #{fulltext_mode})"
end