Chapter 7. Searching

Table of Contents

Sensei Request
Load Balancing
RESTful API
Scalar Parameters
Sort Fields Parameter
Query Parameters
Selection Parameters
Facet Specification Parameters

Once the indexing process is started and some data has been indexed, you can start to perform searches against the Sensei cluster. A search query is done by building a Sensei request and sending it to a Sensei broker. You can do this using a native Java Sensei client, or other client APIs that support other languages like Python or JavaScript.

Upon receiving a request, a Sensei broker passes it to a set of selected Sensei nodes, merges the search results from these nodes, and then returns the merged results back to the requester. What set of Sensei nodes are selected for a request is decided using load balancer. Based on the need of the applications, you can plug in different customized load balancers. By default, Sensei uses a load balancer that distributes work load based on consistent hashing.

Sensei Request

A Sensei request contains the following main parameters:

  • Query: the input query string

  • Offset: the starting offset of search results

  • Count: the number of search results to return

  • Initializing parameters for runtime facet handlers: a map that contains the initializing parameters that are needed by all runtime facet handlers

  • Flag indicating whether stored fields are to be fetched

  • Partitions: shards of the index to be searched

  • Flag indicating whether explanation information should be returned

  • Routing parameter: the field value used for routing

  • Group-by field: the field name used for the group-by operation (also called field collapsing )