Search in sources :

Example 61 with RestHighLevelClient

use of org.elasticsearch.client.RestHighLevelClient in project datashare by ICIJ.

the class CommonMode method configure.

@Override
protected void configure() {
    bind(PropertiesProvider.class).toInstance(propertiesProvider);
    bind(LanguageGuesser.class).to(OptimaizeLanguageGuesser.class);
    String batchQueueType = propertiesProvider.get("batchQueueType").orElse("org.icij.datashare.extract.MemoryBlockingQueue");
    bind(new TypeLiteral<BlockingQueue<String>>() {
    }).toInstance(getBlockingQueue(propertiesProvider, batchQueueType, "ds:batchsearch:queue"));
    bind(new TypeLiteral<BlockingQueue<BatchDownload>>() {
    }).toInstance(getBlockingQueue(propertiesProvider, batchQueueType, "ds:batchdownload:queue"));
    RestHighLevelClient esClient = createESClient(propertiesProvider);
    bind(RestHighLevelClient.class).toInstance(esClient);
    bind(Indexer.class).to(ElasticsearchIndexer.class).asEagerSingleton();
    bind(TaskManagerMemory.class).toInstance(new TaskManagerMemory(propertiesProvider));
    install(new FactoryModuleBuilder().build(TaskFactory.class));
    if ("memory".equals(propertiesProvider.getProperties().get("queueType"))) {
        bind(DocumentCollectionFactory.class).to(MemoryDocumentCollectionFactory.class).asEagerSingleton();
    } else {
        install(new FactoryModuleBuilder().implement(DocumentQueue.class, RedisUserDocumentQueue.class).implement(ReportMap.class, RedisUserReportMap.class).build(DocumentCollectionFactory.class));
    }
    DataBus dataBus;
    if ("memory".equals(propertiesProvider.getProperties().get("busType"))) {
        dataBus = new MemoryDataBus();
    } else {
        dataBus = new RedisDataBus(propertiesProvider);
    }
    bind(DataBus.class).toInstance(dataBus);
    bind(Publisher.class).toInstance(dataBus);
    PipelineRegistry pipelineRegistry = new PipelineRegistry(propertiesProvider);
    pipelineRegistry.register(EmailPipeline.class);
    pipelineRegistry.register(Pipeline.Type.CORENLP);
    try {
        pipelineRegistry.load();
    } catch (FileNotFoundException e) {
        LoggerFactory.getLogger(getClass()).info("extensions dir not found " + e.getMessage());
    }
    bind(PipelineRegistry.class).toInstance(pipelineRegistry);
}
Also used : BatchDownload(org.icij.datashare.batch.BatchDownload) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) FileNotFoundException(java.io.FileNotFoundException) MemoryDataBus(org.icij.datashare.com.MemoryDataBus) RedisUserDocumentQueue(org.icij.datashare.extract.RedisUserDocumentQueue) DocumentQueue(org.icij.extract.queue.DocumentQueue) RestHighLevelClient(org.elasticsearch.client.RestHighLevelClient) DataBus(org.icij.datashare.com.DataBus) MemoryDataBus(org.icij.datashare.com.MemoryDataBus) RedisDataBus(org.icij.datashare.com.RedisDataBus) Publisher(org.icij.datashare.com.Publisher) TaskManagerMemory(org.icij.datashare.tasks.TaskManagerMemory) PipelineRegistry(org.icij.datashare.extension.PipelineRegistry) PropertiesProvider(org.icij.datashare.PropertiesProvider) MemoryDocumentCollectionFactory(org.icij.datashare.tasks.MemoryDocumentCollectionFactory) TypeLiteral(com.google.inject.TypeLiteral) MemoryDocumentCollectionFactory(org.icij.datashare.tasks.MemoryDocumentCollectionFactory) DocumentCollectionFactory(org.icij.datashare.tasks.DocumentCollectionFactory) TaskFactory(org.icij.datashare.tasks.TaskFactory) RedisDataBus(org.icij.datashare.com.RedisDataBus) OptimaizeLanguageGuesser(org.icij.datashare.nlp.OptimaizeLanguageGuesser) LanguageGuesser(org.icij.datashare.text.indexing.LanguageGuesser) ElasticsearchIndexer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchIndexer) RedisUserDocumentQueue(org.icij.datashare.extract.RedisUserDocumentQueue)

Example 62 with RestHighLevelClient

use of org.elasticsearch.client.RestHighLevelClient in project vorto by eclipse.

the class ElasticSearchConfiguration method awsIndexingClient.

@Bean
@Profile({ "prod", "int" })
public RestHighLevelClient awsIndexingClient() {
    logger.info("Creating an elastic server client with config(serviceName=" + serviceName + " region=" + region + " aesEndpoint=" + aesEndpoint);
    AWS4Signer signer = new AWS4Signer();
    signer.setServiceName(serviceName);
    signer.setRegionName(region);
    HttpRequestInterceptor interceptor = new AWSRequestSigningApacheInterceptor(serviceName, signer, credentialsProvider);
    RestClientBuilder builder = RestClient.builder(HttpHost.create(aesEndpoint)).setHttpClientConfigCallback(httpClientConfig(getProxy(), interceptor));
    return new RestHighLevelClient(builder);
}
Also used : AWS4Signer(com.amazonaws.auth.AWS4Signer) HttpRequestInterceptor(org.apache.http.HttpRequestInterceptor) RestClientBuilder(org.elasticsearch.client.RestClientBuilder) AWSRequestSigningApacheInterceptor(com.amazonaws.http.AWSRequestSigningApacheInterceptor) RestHighLevelClient(org.elasticsearch.client.RestHighLevelClient) Profile(org.springframework.context.annotation.Profile) Bean(org.springframework.context.annotation.Bean)

Aggregations

RestHighLevelClient (org.elasticsearch.client.RestHighLevelClient)61 HttpHost (org.apache.http.HttpHost)23 RestClientBuilder (org.elasticsearch.client.RestClientBuilder)21 IOException (java.io.IOException)14 RestClient (org.elasticsearch.client.RestClient)13 HashMap (java.util.HashMap)10 IndexRequest (org.elasticsearch.action.index.IndexRequest)8 RequestOptions (org.elasticsearch.client.RequestOptions)7 Test (org.junit.jupiter.api.Test)7 CredentialsProvider (org.apache.http.client.CredentialsProvider)6 SearchRequest (org.elasticsearch.action.search.SearchRequest)6 SearchResponse (org.elasticsearch.action.search.SearchResponse)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Map (java.util.Map)5 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)5 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)5 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)5 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)5