Skip to main content

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.

Jump to: navigation, search

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 ElasticsearchTemplate and ElasticsearchTemplateAsync 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 Template

ElasticsearchTemplateAsync and ElasticsearchTemplate are specialized classes from DocumentTemplate and DocumentTemplateAsync 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 ElasticsearchTemplate template;

public void sample() {
        QueryBuilder queryBuilder = boolQuery().filter(termQuery("name", "Ada"));
        List<Person> people = template.search(queryBuilder, "Person");
}


Links

Back to the top