-
Notifications
You must be signed in to change notification settings - Fork 21
Indexing
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 thesearch
method. Any number of attributes can be passed here. -
field
Indexes the passed attributes as attribute values for searching through thewhere
method. Any number of attributes can be passed here. -
sortable
Allows the passed attributes to be sorted using theorder
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 thefacets
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"
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