2/ENGINE (Search Engine API)
License
Copyright (c) 2021 the Editor and the Contributors.
This specification is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Language
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
Overview
Use Case
To allow easy addition of new search engines the API of the base class (SearchEngine) SHOULD be lightweight and straightforward. A developer SHOULD be able to implement their own engine quickly by following the appropriate documents and source code.
Design of the API
The API for the SearchEngine class exposes several functions which have to be implemented by an actual search engine class.
Technical Specification
- The engine MUST be implemented in the
engines
modules in thecom.wegtam.search.engines
package. - The engine MUST implement the SearchEngine interface.
- The parser of the engine MUST implement the SearchEngineParser interface.
- The
name
of the implemented engine MUST be unique. - The implemented engine MUST be added to the
all
function of the SearchEnginesLoader object.
SearchEngine Interface
The interface MUST provide the following functions which SHALL be implemented by a concrete search engine implementation:
capabilities
- MUST return the capabilities that the search engine supports and that
are implemented.
- MUST return the capabilities that the search engine supports and that
modes
- MUST return all supported and implemented search modes of the engine.
This list MUST never be empty because at least one mode is supported.
- MUST return all supported and implemented search modes of the engine.
name
- MUST return the unique search engine name.
parser
- MUST return the implementation of the parser for the search engine.
search
- MUST perform the actual search and return a stream with the parsed results.