Service classes and features

Last updated on
24 March 2017

This page explains the Search API concept of features and lists all known service classes currently available.

Features

Service classes in the Search API have to provide clearly-defined services to make indexing and searching work as expected. However, especially when connecting external search services to the Search API, they are usually capable of more than just the base functionality the Search API requires. Features are a way of describing these additional capabilities so other modules can make use of them, even while still remaining backend-independent (although no longer server-independent, as the server an index lies on now matters).

A feature is a clearly-defined piece of functionality a service class can optionally implement and provide to other modules. For instance, it could involve recognizing an additional option on the search query object and acting accordingly, or implementing an additional method in the service class, etc. Features are defined by the third-party modules using them, which should include a detailed description of the contract service classes implementing the feature have to fulfill.

Currently known features

The following is a list with descriptions of all currently known features.

search_api_autocomplete
Defined/used by: Search API autocomplete
Description: Allows autocompletion of fulltext keywords in search forms (along with result count estimates).
search_api_facets
Defined/used by: D7: Search facets (part of the Search API project); D8: Facets
Description: Allows facetted searching, with facets showing possible filter options.
search_api_facets_operator_or
Defined/used by: D7: Search facets (part of the Search API project); D8: Facets
Description: Along with the search_api_facets feature, allows the creation of „OR“ facets, i.e., facets which yield more results when more than one facet term is activated.
search_api_data_type_TYPE
Defined/used by: Search API
Description: This is a group of special / "magic" features which is defined and recognized by the Search API itself. With this feature, service classes show that they support the data type TYPE. If the data type is also defined with a hook_search_api_data_type_info() implementation, it becomes possible to index fields with that data type on servers with that service class.
Currently known types:
search_api_grouping
Defined/used by: Search API Grouping
Description: Allows grouping of results based on the value of one or more fields.
search_api_mlt
Defined/used by: Search views (part of the Search API project)
Description: Allows „More Like This“ queries, in which an item ID is given and the search should return items that are similar (according to the indexed data, in some way) to the specified item.
search_api_multi
Defined/used by: Search API multi-index searches
Description: Allows the parallel search of multiple indexes on the same server with a single query.
search_api_random
Defined/used by: Search views (part of the Search API project)
Description: Allows to randomly sort the results returned by a search. With a server supporting this, you can use the "Global: Random" to sort the View's results randomly. Every time the query is run a different sorting will be provided.
search_api_spellcheck
Defined/used by: Search API Spellcheck
Description: Allows spellchecking the keywords used in a search, by returning similar words that would yield more results.

Service classes

As previously explained, a service class is a concrete method how data is indexed and searched. The following service classes are currently available:

  1. Database service (DB; contained directly in the "Search API" project in Drupal 8)
  2. Solr service (Solr)
  3. Xapian local service (Xapian Local): in the Xapian for Search API project API module contained in the Xapian project
  4. Xapian server service (Xapian Server): in the Xapian for Search API project API module contained in the Xapian project
  5. MongoDB service (Mongo)
  6. Sphinx service
  7. Elasticsearch service

The following table shows the current state of which features are supported by which service class.

Feature DB Solr Xapian Local Xapian Server Mongo Sphinx Elasticsearch
search_api_autocomplete Yes Yes No No No No Yes
search_api_facets Yes Yes No No No Yes Yes
search_api_facets_operator_or Yes Yes No No No Yes Yes
search_api_data_type_location No Yes No No No No Yes
search_api_data_type_geohash No Yes No No No No No
search_api_grouping No Yes No No No No No
search_api_mlt No Yes No No No Yes Yes
search_api_multi No Yes No No No No Yes
search_api_random No Yes No No No No No
search_api_spellcheck No Yes No No No No No

Yes = Service class supports this feature
No = Service class doesn't support this feature