-
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.
-
textIndexes the passed attributes as text terms so they will be searchable through thesearchmethod. Any number of attributes can be passed here. -
fieldIndexes the passed attributes as attribute values for searching through thewheremethod. Any number of attributes can be passed here. -
sortableAllows the passed attributes to be sorted using theordersearch method. Any number of attributes can be passed here. -
facetMakes the passed attribute a facet. This will cause it to be returned by thefacetsmethod. 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