lib/xapian_db/config.rb in xapian_db-1.3.2 vs lib/xapian_db/config.rb in xapian_db-1.3.3

- old
+ new

@@ -51,25 +51,29 @@ def term_min_length @config.instance_variable_get("@_term_min_length") || 1 end - def phrase_search_enabled? - @config.instance_variable_get("@_phrase_search_enabled") || false - end - def term_splitter_count @config.instance_variable_get("@_term_splitter_count") || 0 end + + def query_flags + @config.instance_variable_get("@_enabled_query_flags") || [ Xapian::QueryParser::FLAG_WILDCARD, + Xapian::QueryParser::FLAG_BOOLEAN, + Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE, + Xapian::QueryParser::FLAG_SPELLING_CORRECTION + ] + end end # --------------------------------------------------------------------------------- # DSL methods # --------------------------------------------------------------------------------- - attr_reader :_database, :_adapter, :_writer, :_beanstalk_daemon, :_resque_queue, :_stemmer, :_stopper, :_term_min_length, - :_phrase_search_enabled, :_term_splitter_count + attr_reader :_database, :_adapter, :_writer, :_beanstalk_daemon, :_resque_queue, :_stemmer, :_stopper, + :_term_min_length, :_term_splitter_count, :_enabled_query_flags # Set the global database to use # @param [String] path The path to the database. Either apply a file sytem path or :memory # for an in memory database def database(path) @@ -151,21 +155,22 @@ # @param [Integer] length The minimum length def term_min_length(length) @_term_min_length = length end - # Enable phrase search support ("search this exact sentence") - def enable_phrase_search - @_phrase_search_enabled = true + def term_splitter_count(count) + @_term_splitter_count = count end - # Disable phrase search support ("search this exact sentence") - def disable_phrase_search - @_phrase_search_enabled = false + def enable_query_flag(flag) + @_enabled_query_flags ||= [] + @_enabled_query_flags << flag + @_enabled_query_flags.uniq! end - def term_splitter_count(count) - @_term_splitter_count = count + def disable_query_flag(flag) + @_enabled_query_flags ||= [] + @_enabled_query_flags.delete flag end - end + end end