Search in sources :

Example 1 with Index

use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.

the class ElasticsearchService method explain.

public Explanation explain(EntityType entityType, Object entityId, Query<Entity> q) {
    Index index = contentGenerators.createIndex(entityType);
    Document document = contentGenerators.createDocument(entityId);
    QueryBuilder query = contentGenerators.createQuery(q, entityType);
    return clientFacade.explain(SearchHit.create(document.getId(), index.getName()), query);
}
Also used : Index(org.molgenis.data.elasticsearch.generator.model.Index) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) Document(org.molgenis.data.elasticsearch.generator.model.Document)

Example 2 with Index

use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.

the class ElasticsearchService method count.

@Override
public long count(EntityType entityType, Query<Entity> q) {
    Index index = contentGenerators.createIndex(entityType);
    QueryBuilder queryBuilder = contentGenerators.createQuery(q, entityType);
    return clientFacade.getCount(queryBuilder, index);
}
Also used : Index(org.molgenis.data.elasticsearch.generator.model.Index) QueryBuilder(org.elasticsearch.index.query.QueryBuilder)

Example 3 with Index

use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.

the class ElasticsearchService method aggregate.

@Override
public AggregateResult aggregate(final EntityType entityType, AggregateQuery aggregateQuery) {
    List<AggregationBuilder> aggregationList = contentGenerators.createAggregations(aggregateQuery.getAttributeX(), aggregateQuery.getAttributeY(), aggregateQuery.getAttributeDistinct());
    QueryBuilder query = contentGenerators.createQuery(aggregateQuery.getQuery(), entityType);
    Index index = contentGenerators.createIndex(entityType);
    Aggregations aggregations = clientFacade.aggregate(aggregationList, query, index);
    return new AggregateResponseParser().parseAggregateResponse(aggregateQuery.getAttributeX(), aggregateQuery.getAttributeY(), aggregateQuery.getAttributeDistinct(), aggregations, dataService);
}
Also used : AggregationBuilder(org.elasticsearch.search.aggregations.AggregationBuilder) Aggregations(org.elasticsearch.search.aggregations.Aggregations) Index(org.molgenis.data.elasticsearch.generator.model.Index) QueryBuilder(org.elasticsearch.index.query.QueryBuilder)

Example 4 with Index

use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.

the class ElasticsearchService method index.

@Override
public void index(EntityType entityType, Entity entity) {
    Index index = contentGenerators.createIndex(entityType);
    Document document = contentGenerators.createDocument(entity);
    clientFacade.index(index, document);
}
Also used : Index(org.molgenis.data.elasticsearch.generator.model.Index) Document(org.molgenis.data.elasticsearch.generator.model.Document)

Example 5 with Index

use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.

the class ElasticsearchService method deleteById.

@Override
public void deleteById(EntityType entityType, Object entityId) {
    Index index = contentGenerators.createIndex(entityType);
    Document document = contentGenerators.createDocument(entityId);
    clientFacade.deleteById(index, document);
}
Also used : Index(org.molgenis.data.elasticsearch.generator.model.Index) Document(org.molgenis.data.elasticsearch.generator.model.Document)

Aggregations

Index (org.molgenis.data.elasticsearch.generator.model.Index)37 Test (org.junit.jupiter.api.Test)23 ElasticsearchException (org.elasticsearch.ElasticsearchException)13 SearchRequest (org.elasticsearch.action.search.SearchRequest)10 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)6 CreateIndexRequest (org.elasticsearch.client.indices.CreateIndexRequest)6 IOException (java.io.IOException)5 CountRequest (org.elasticsearch.client.core.CountRequest)5 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)5 IndexSettings (org.molgenis.data.elasticsearch.generator.model.IndexSettings)5 Mapping (org.molgenis.data.elasticsearch.generator.model.Mapping)5 UnknownIndexException (org.molgenis.data.index.exception.UnknownIndexException)5 ResourceNotFoundException (org.elasticsearch.ResourceNotFoundException)4 GetIndexRequest (org.elasticsearch.client.indices.GetIndexRequest)4 IndexRequest (org.elasticsearch.action.index.IndexRequest)3 Document (org.molgenis.data.elasticsearch.generator.model.Document)3 FieldMapping (org.molgenis.data.elasticsearch.generator.model.FieldMapping)3 ElasticsearchStatusException (org.elasticsearch.ElasticsearchStatusException)2 DeleteRequest (org.elasticsearch.action.delete.DeleteRequest)2 SearchResponse (org.elasticsearch.action.search.SearchResponse)2