Selects the specified number of results. If you do not use this method, a maximum of 10 results is returned.
search_request requesting(int number)
search_request | the modified search request |
entity_type("foo").requesting(100) --> maximum 100 results
subject.association1.requesting(5).association2.requesting(20) --> maximum 20 results
Selects the specified number of results searched for the preceding entity type in this search request. Applies when multiple entity types or an association is specified. If only one entity type is specified in the search request, this method is ignored. If an association request is specified and you do not use this method, each association segment searches a maximum of 250 entities per association segment.
search_request requesting_per_entity_type(int number)
search_request | the modified search request |
entity_types(["foo", "bar"]).requesting_per_entity_type(50) -> maximum of 50 for both "foo" and 50 "bar" searched
subject.association1.association2.requesting_per_entity_type(50) -> maximum of 250 for association1 (default) and maximum of 50 for association2 entity types searched
Selects results starting at the specified position in the result set. The parameter must be a number greater than or equal to 0. If you do not use this method, the default position is 0.
search_request starting_at(int number)
search_request | the modified search request |
entity_type("foo").starting_at(30) --> results are from 30 to 40 (if requesting is default 10)
Selects results according to the subsequent filters specified by the query parameter. The parameter can either be a string or a query expression.
search_request where(query/data_method/string query)
entity_type("foo").where("bar") --> returns entities of type "foo" with "bar" in it
entity_type("foo").where(field("bar").contains_regex("a.+")) --> returns entities of type "foo" with values of field "bar" matching the regex
Selects a specified set of results by running the query parameter before running the main query. This query will not affect relevance of actual results. Multiple calls to this method are equivalent to combining queries with AND. The parameter can either be a string or a query expression.
search_request with_filter_query(query/data_method/string query)
entity_type("foo").with_filter_query(field("bar").exists) --> returns entities of type "foo" with a "bar" field without affecting result relevancy
Selects results according to the query parameter, which overrides previous queries in this search request. The parameter can either be a string or a query expression.
search_request set_query(query/data_method/string query)
entity_type("foo").where("foo").set_query("bar") --> returns entities of type "foo" that match "bar" ("foo" is ignored)
Enables clustering of the returned results. The clustered results can be retrieved from the faceting configuration. If you do not use this method, results will not be clustered in the faceting configuration.
search_request clustered
entity_type("foo").clustered --> allows retrieval of a facet id "%clustering%" from the faceting configuration
Enables filtering of duplicate entities. If you do not use this method, all results are returned, including duplicates.
search_request filter_duplicates
entity_type("foo").filter_duplicates --> returns entities of type "foo" without duplicates
Specifies a faceting configuration. The parameter is a faceting expression.
search_request faceted_by(facet_by/data_method facet_by)
entity_type("foo").faceted_by( field("bar").then( sum("baz" ) ) ) --> allows the faceting configuration to contain results grouped by value of "bar" each with the sum of "baz"
Specifies a sorting expression. The parameter is a sorting expression. Default order is by relevancy. Use sorted_by( field("last_name").then( field("first_name") ) to combine multiple sorting conditions. Order of calls corresponds to sorting precedence.
search_request sorted_by(sort_by/data_method sort_by)
entity_type("foo").sorted_by(field("bar").in_descending_order) --> results sorted by value of "bar" in reverse order
entity_type("foo").sorted_by( field( "last_name" ).then( field( "first_name" ) ) ) --> results sorted by value of "last_name" then by "first_name"
Specifies named fields to return. Fields specified here overwrite (replace) fields specified in previous calls to selecting_fields method. If you do not use this method, all fields are returned.
search_request selecting_fields(array fields_array)
entity_type("foo").selecting_fields( [ "bar", "baz" ] ) --> contains only "bar" and "baz" fields in the results
Generate snippets with this request. Search results will have "snippet" field containing a short excerpt from the text of the entity.
search_request generate_snippets
entity_type("foo").generate_snippets --> entities returned have an additional field called "snippet" available
Embolden fields and snippets based on query. Search results will have HTML tags surrounding matching portions of the query. This method has no effect unless used with a filtering method like the where method.
search_request bold
entity_type("foo").where("bar").bold --> entities returned have HTML tags surrounding "bar" in fields of the entity
Specify a default sort using XPath to the last step of the query. A formula specified here overwrites (replaces) formulae specified in previous calls to the method with_relevance_formula(xpath).
search_request with_relevance_formula(string xpath)
entity_type("foo").with_relevance_formula("-$score") --> reverses the order of the results
(Ruby method) Returns a string representing the search request.
string to_s
(Rails method) Returns a JSON respresentation of the search request.
string to_json
(Rails method) Returns an XML respresentation of the search request.
string to_xml
(Ruby method) Calls the given block once for each result in the search results passing that result as a parameter. An Enumerator is returned if no block is given.
(Ruby method) Returns the first search result. If the results are empty, returns nil.
search_result first
(Ruby method) Returns true if the search request returns no results.
boolean empty?
Returns the total number of results. If that cannot be calculated, the actual number of results returned.
int total_results
entity_type("foo").total_results --> integer that represents total results, not results returned
Returns the total number of results after removing duplicates. If the total number cannot be calculated, the actual number of results is returned. The returned value is usually only meaningful when the filter_duplicates method is called. The returned value is likely to be an approximation unless it is lower than the rank of the last result requested.
int total_results_without_duplicates
entity_type("foo").filter_duplicates.total_results_without_duplicates --> integer that represents total results without duplicates
Returns the number of results that are actually returned in this request. Is less than or equal to the number set by the requesting method.
int size
Returns a faceting configuration that represents the grouping done on the request.
faceting faceting
entity_type("foo").faceted_by( field("bar") ).faceting --> returns faceting configuration with "bar" as a facet