ryanb edited this page Aug 17, 2011 · 1 revision

When running the rails g xapit:install command it will generate a configuration file in config/xapit.yml. Each Rails environment can have a different set of configuration options. Here is a list of each option.

  • enabled determines if Xapit is on initially. Records created while it is disabled will not be indexed automatically. Trying to perform a search will result in a Xapit::Disabled exception. Pass Xapit.enable to enable it. Defaults to true.
  • spelling causes records to be indexed with spelling terms. The spelling_suggestion method will still work when this is disabled, it will just not return any results. Defaults to true.
  • stemming specifies which language to be used when stemming. Any language that Xapian supports can be used here. Pass nothing here to disable stemming. Defaults to english.
  • database_path is path to the database file relative to the project root directory. If no database path is specified it will use an in-memory store. Defaults to no path.
  • server is the URL to the Xapit server which can be started with the included rackup file. If you have multiple processes needing to connect to the database (such as in production) it is important to use this server option because only one process can write to the database. If nothing is specified it will use a local database. Defaults to nothing.

In Rails the config/xapit.yml file is loaded automatically when the app starts. You can reload the configuration at any time by doing Xapit.reload. It is also possible to load the configuration file manually:

Xapit.reset_config # set to default config options
Xapit.load_config("path/to/xapit.yml", "development")