Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Indexing

ryanb edited this page Aug 17, 2011 · 1 revision

Defining Index

To enable Xapit indexing on a model, call xapit and pass in a block. Here are the four methods which you can call inside this block. Currently only Active Record is supported but additional ORMs will be in the near future.

  • text Indexes the passed attributes as text terms so they will be searchable through the search method. Any number of attributes can be passed here.

  • field Indexes the passed attributes as attribute values for searching through the where method. Any number of attributes can be passed here.

  • sortable Allows the passed attributes to be sorted using the order search method. Any number of attributes can be passed here.

  • facet Makes the passed attribute a facet. This will cause it to be returned by the facets method. Only one attribute can be passed in here at a time. If a second argument is given it is used as the name of the facet. For example: facet :author_name, "Author"

Performing Index

The index automatically occurs when a record is created, updated, or destroyed. To re-index all of the records, run this rake task.

rake xapit:index

You can also do this through Ruby (such as in a test).

Xapit.index(Article, Comment) # pass in any model classes you want to index
Clone this wiki locally