Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
JNoSQL/Artemis/Elasticsearch
Elasticsearch Extension
The goal of an extension goes beyond the Artemis API-core, and with Elasticsearch Extensions it does not look different. Elasticsearch Extension has classes such as ElasticsearchDocumentRepository and ElasticsearchDocumentRepositoryAsync whose have support to Elasticsearch particular behavior as query builder.
Maven Dependency
To use the Elasticsearch extension to Artemis:
<dependency>
<groupId>org.jnosql.artemis</groupId>
<artifactId>elasticsearch-extension</artifactId>
<version>version</version>
</dependency>
E.g:
<dependency>
<groupId>org.jnosql.artemis</groupId>
<artifactId>elasticsearch-extension</artifactId>
<version>0.0.1</version>
</dependency>
Elastisearch Document Repository
ElasticsearchDocumentRepositoryAsync and ElasticsearchDocumentRepository are specialized classes from DocumentRepository and DocumentRepositoryAsync respectively, so they have all methods plus the Elasticsearch methods whose has in Elasticsearch driver such as ES query builder. To active, this resource just needs to produce an ElasticsearchDocumentCollectionManager in a CDI context.
@Produces
public ElasticsearchDocumentCollectionManager getManager() {
//code
return managerFactory.get(KEY_SPACE);
}
Done, the Artemis will take and manage the bean to you.
@Inject
private ElasticsearchDocumentRepository columnRepository;
public void sample() {
QueryBuilder queryBuilder = boolQuery().filter(termQuery("name", "Ada"));
List<Person> people = repository.find(queryBuilder, "Person");
}
The similar thing happens with the CassandraColumnRepositoryAsync just produces the CassandraColumnFamilyManagerAsync.
@Produces
public ElasticsearchDocumentCollectionManagerAsync getManagerAsync() {
//code
return managerFactory.get(KEY_SPACE);
}