Clone this wiki locally
Whenever you call
search on a model it will return a Xapit Collection instance. You can also call
Xapit.search to do a global search across all indexed models. Here are the various search methods you can call which all return another Collection instance so they can be chained.
searchPass a text string to query
wherePass a hash of conditions to query
or_wherePerform an OR search on where clauses.
orderPass in a
sortableattribute to sort by followed by an optional direction (
pageThe page number of records to return.
perThe number of records per page.
with_facetsPass in a list of facets to limit the search by.
similar_toPass in a model instance to find similar records.
in_classesPass in any number of classes to use in
not_in_classesPass in any number of classes to exclude from
The collection instance behaves like an array, so you can easily fetch all of the records by iterating through it. Here are some of the other methods it supports.
recordsThe array of records, all array methods are delegated to this so it is usually not necessary to call directly.
total_entriesThe number of records found in the search across all pages.
total_pagesThe total number of pages, also aliased as
current_pageThe current page you're on.
limit_valueThe number of records per page.
applied_facet_optionsAn array of
FacetOptioninstances which have been applied to the search.
facetsAn array of
Facetinstances to search by.
spelling_suggestionA suggested term instead of the one queried on.
The string passed to the
search method can include
NOT to do boolean searches. It can also include
* to perform partial matches.