This repository was archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Searching
ryanb edited this page Aug 17, 2011
·
1 revision
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 querytextattributes. -
wherePass a hash of conditions to queryfieldattributes. -
not_whereInverse ofwhere. -
or_wherePerform an OR search on where clauses. -
orderPass in asortableattribute to sort by followed by an optional direction (:ascor:desc) -
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 inXapit.search. -
not_in_classesPass in any number of classes to exclude fromXapit.search.
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 asnum_pages -
current_pageThe current page you're on. -
limit_valueThe number of records per page. -
applied_facet_optionsAn array ofFacetOptioninstances which have been applied to the search. -
facetsAn array ofFacetinstances to search by. -
spelling_suggestionA suggested term instead of the one queried on.
The string passed to the search method can include AND, OR or NOT to do boolean searches. It can also include * to perform partial matches.