Only a few steps are necessary to get started with a standard configuration.
Several code examples can be found here.
picturesafe-search requires a running Elasticsearch server from version 7.x.
Local installation of Elasticsearch
For a new application an Elasticsearch server must be installed first:
Download and unpack the Elasticsearch official distribution.
bin/elasticsearch on Linux or macOS. Run
bin\elasticsearch.bat on Windows.
Some features of picturesafe-search (for example sorting documents in a language-specific word order) require the ICU Analysis Plugin for Elasticsearch:
bin/elasticsearch-plugin install analysis-icu on Linux or macOS. Run
bin\elasticsearch-plugin install analysis-icu on Windows.
Run Elasticsearch in a Docker container
As an alternative to installing Elasticsearch you can run it in a Docker container. To do this you can use the provided Docker Compose file.
- Install Docker and Docker Compose.
- Clone the picturesafe-search GitHub repository.
docker-compose -f src/test/docker/docker-compose.yml up -d from the project directory to start Elasticsearch.
- To stop Elasticsearch run
docker-compose -f src/test/docker/docker-compose.yml stop from the project directory.
Include java library
Add the current version of the picturesafe-search library to your project.
Implement a configuration class that imports the
This configuration can be extended later.
The following example defines three fields for the Elasticsearch index:
- Field ‘id’ (Elasticsearch type text, sortable)
- Field ‘fulltext’ (Elasticsearch type text)
- Field ‘title’ (Elasticsearch type text, within fulltext, aggregatable, sortable)
- Field ‘count’ (Elasticsearch type integer, sortable)
Add a file
elasticsearch.properties to the classpath of your application and define the following key (this configuration can be extended later):
Inject the SingleIndexElasticsearchService and implement an expression-based search:
- Create an Elasticsearch index with alias
- Add some documents to the index
- Create an
OperationExpression with two terms
- Run the search query
- Delete the Elasticsearch index
If you want to implement searches for more than one index, please use
ElasticsearchService instead of
Spring service implementation
With implementations of the picturesafe-search
Expression-Interface complex terms of different search conditions can be easily defined.
Here are some examples:
Simple fulltext search
Simple field search
Simple field search with comparison operator
Search with two terms
In addition there are further