This repository has been 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.
-
search
Pass a text string to querytext
attributes. -
where
Pass a hash of conditions to queryfield
attributes. -
not_where
Inverse ofwhere
. -
or_where
Perform an OR search on where clauses. -
order
Pass in asortable
attribute to sort by followed by an optional direction (:asc
or:desc
) -
page
The page number of records to return. -
per
The number of records per page. -
with_facets
Pass in a list of facets to limit the search by. -
similar_to
Pass in a model instance to find similar records. -
in_classes
Pass in any number of classes to use inXapit.search
. -
not_in_classes
Pass 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.
-
records
The array of records, all array methods are delegated to this so it is usually not necessary to call directly. -
total_entries
The number of records found in the search across all pages. -
total_pages
The total number of pages, also aliased asnum_pages
-
current_page
The current page you're on. -
limit_value
The number of records per page. -
applied_facet_options
An array ofFacetOption
instances which have been applied to the search. -
facets
An array ofFacet
instances to search by. -
spelling_suggestion
A 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.