Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Search API has a versatile search engine solution designed to seamlessly connect with any NonSQL engine. It offers a unified interface for interacting with different search engines, allowing you to utilize the same code for every request. The Search API achieves this through its implementation-defined integration with specific search engines while maintaining consistency in its usage.


Key Features

  1. Search Engine Agnosticism: The Search API is designed to be independent of any particular search engine. It provides a flexible and adaptable solution that can seamlessly integrate with various NonSQL engines.

  2. Universal Code Usage: With the Search API, you can utilize the same code for all search engine requests. Regardless of the underlying search engine implementation, the API provides a consistent interface to interact with.

  3. Normalization of Parameters and Responses: The Search API incorporates a normalization process for parameters and responses. This normalization ensures that requests and results are interpreted uniformly across different search engine implementations.

  4. Implementation-Specific Integration: Each specific search engine implementation is responsible for interpreting and executing the normalized parameters and responses. The Search API facilitates this integration by providing a standardized interface, allowing for efficient communication between the API and the search engine.

Table of Contents

Connection Manager

The connection manager is in charge of the loading of the connection configurations and the initialization with every engine specific implementation. It is also in charge to open and close the connection, pool size, throttling, node balancing,...

Accessing the Connection Manager in Code

You can get the connection Manager in your code using:

Code Block
languagepy
themeDJango
from app.rest import connection_manager

Getting Connection by Default

The default connection is the engine connection with the explicit default flag in true, or if none with the flag, the first in the list of connections. This connection is used as well for all internal transactions of Search API  such as logging, feedback, analytics,...

To get the default connection, just use the code line below: 

Code Block
languagepy
themeDJango
self.engine_conn = connection_manager.get_default()

Getting Connection by name

You can have multiple connections to the same or different types of NonSQL engines, all with a name you can refer to, in order to get said connection. 

To get a connection by name, just use the code line below:

Code Block
languagepy
themeDJango
self.engine = connection_manager.get_engine(name=engine_name)

Engine Connection Config

All engine connections have the generic connection focus on managing the specific aspects of the REST connection.

PropertyDescriptionDefaultTypeRequired
nameSpecify the name of this engine
string (pattern: "[a-zA-Z\d_-]+")Yes
typeType of the engine to use for searches
string (enum: "elasticsearch", "opensearch")Yes
defaultIf more than one, default = True indicates which engines will be used for Search API storagefalsebooleanNo
engine_urlURLs to the engine nodes
string or array of strings (minLength: 1, maxLength: 65536, format: uri)Yes
index_prefixPrefix for all search API indexes"sa"string (pattern: "[a-zA-Z\d_]+")No
pool_connectionsThe number of connection pools to cache10integerNo
pool_maxsizeThe maximum number of connections to save in the pool.100integerNo
pool_blockWhether the connection pool should block for connections.falsebooleanNo
headersDictionary with the predefined headers, express has header name (key), and its value{}objectNo
proxies
{}objectNo
paramsDictionary with the predefined parameters, express has parameter name (key), and its value{}objectNo
auth

objectNo
verifyDefaults to True, requiring requests to verify the TLS certificate at the remote end.truebooleanNo
cookiesDictionary with the predefined cookies, express has cookie name (key), and its value{}objectNo
cert

string or array or string or file-pathNo
max_redirectsMaximum times the request is allowed to be redirected.30integer (minimum: 1)No
max_retriesNumber of times the server will retry a failed request before throwing an error.10integer (minimum: 0)No
retry_backoff_factorA backoff factor to apply between attempts after the second try. The connection will sleep for {backoff factor} * (2 ** ({number of total retries} - 1)) seconds. If the backoff_factor is 0.1, then will sleep for [0.0s, 0.2s, 0.4s, ...] between retries2.5number (minimum: 0)No
retry_on_timeoutShould timeout trigger a retry on a different node?falsebooleanNo
timeoutMaximum time the server will wait for a request to be answered.30integer (minimum: 1)No
allow_redirectsAllow the request to be redirectedtruebooleanNo
trust_envTrust environment settings for proxy configuration, default authentication, and similar.truebooleanNo
use_throttlingLimit the number of API requests the server can make in a certain period.falsebooleanNo
throttling_rateNumber of simultaneous calls allowed per minute5000integer (minimum: 100)No
throttling_connection_rate
50integer (minimum: 1)No
randomize_nodes_in_poolSet to false to not randomize nodes within the pool.truebooleanNo
node_selector_classClass to be used to select nodes within the NodePool"round_robin"string (enum: "round_robin", "random")No
dead_node_backoff_factorExponential backoff factor to calculate the amount of time to timeout a node after an unsuccessful API call
numberNo
max_dead_node_backoffMaximum amount of time to timeout a node after an unsuccessful API call
numberNo
log_requestsIf True, every request done by the engine will be loggedfalsebooleanNo