Search in sources :

Example 1 with IIndexFieldExtractor

use of org.eclipse.vorto.repository.search.extractor.IIndexFieldExtractor in project vorto by eclipse.

the class ElasticSearchService method createIndexRequest.

private IndexRequest createIndexRequest(ModelInfo modelInfo, String tenantId) {
    Map<String, Object> jsonMap = new HashMap<>();
    jsonMap.put(TENANT_ID, tenantId);
    for (IIndexFieldExtractor extractor : fieldExtractors) {
        extractor.extractFields(modelInfo).forEach((key, value) -> {
            jsonMap.put(key, value);
        });
    }
    return new IndexRequest(VORTO_INDEX, DOC, modelInfo.getId().getPrettyFormat()).source(jsonMap);
}
Also used : IIndexFieldExtractor(org.eclipse.vorto.repository.search.extractor.IIndexFieldExtractor) IndexRequest(org.elasticsearch.action.index.IndexRequest) GetIndexRequest(org.elasticsearch.client.indices.GetIndexRequest) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) CreateIndexRequest(org.elasticsearch.client.indices.CreateIndexRequest)

Example 2 with IIndexFieldExtractor

use of org.eclipse.vorto.repository.search.extractor.IIndexFieldExtractor in project vorto by eclipse.

the class ElasticSearchService method createMappingForIndex.

private Map<String, Object> createMappingForIndex() {
    Map<String, Object> properties = new HashMap<>();
    properties.put(TENANT_ID, createPropertyWithType(FieldType.KEY));
    for (IIndexFieldExtractor extractor : fieldExtractors) {
        extractor.getFields().forEach((key, value) -> {
            properties.put(key, createPropertyWithType(value));
        });
    }
    Map<String, Object> mapping = new HashMap<>();
    mapping.put("properties", properties);
    return mapping;
}
Also used : IIndexFieldExtractor(org.eclipse.vorto.repository.search.extractor.IIndexFieldExtractor)

Aggregations

IIndexFieldExtractor (org.eclipse.vorto.repository.search.extractor.IIndexFieldExtractor)2 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)1 IndexRequest (org.elasticsearch.action.index.IndexRequest)1 CreateIndexRequest (org.elasticsearch.client.indices.CreateIndexRequest)1 GetIndexRequest (org.elasticsearch.client.indices.GetIndexRequest)1