All Projects → hakdogan → Elasticsearch

hakdogan / Elasticsearch

🌐 This application illustrates and demonstrates use of ElasticSearch Java API in the backend

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Elasticsearch

Fetcher Ts
Type-safe wrapper around Fetch API
Stars: ✭ 87 (-10.31%)
Mutual labels:  rest-client
Systemdlogger
Exports systemd logs to an external service, eg cloudwatch, elasticsearch
Stars: ✭ 91 (-6.19%)
Mutual labels:  elasticsearch
Rumors Api
GraphQL API server for clients like rumors-site and rumors-line-bot
Stars: ✭ 96 (-1.03%)
Mutual labels:  elasticsearch
Search Ui
Search UI. Libraries for the fast development of modern, engaging search experiences.
Stars: ✭ 1,294 (+1234.02%)
Mutual labels:  elasticsearch
Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+10101.03%)
Mutual labels:  elasticsearch
Dynamite Nsm
DynamiteNSM is a free Network Security Monitor developed by Dynamite Analytics to enable network visibility and advanced cyber threat detection
Stars: ✭ 92 (-5.15%)
Mutual labels:  elasticsearch
Homer App
HOMER 7.x Front-End and API Server
Stars: ✭ 88 (-9.28%)
Mutual labels:  elasticsearch
Cccatalog Api
Note: Project is discontinued. The Creative Commons Catalog API allows programmatic access to search for CC-licensed and public domain digital media.
Stars: ✭ 97 (+0%)
Mutual labels:  elasticsearch
Stretcher
Tool designed to help identify open Elasticsearch servers that are exposing sensitive information
Stars: ✭ 91 (-6.19%)
Mutual labels:  elasticsearch
Ansible Elasticsearch
Ansible playbook for Elasticsearch
Stars: ✭ 1,316 (+1256.7%)
Mutual labels:  elasticsearch
Elastic Scout Driver Plus
Extension for Elastic Scout Driver
Stars: ✭ 90 (-7.22%)
Mutual labels:  elasticsearch
Searchspot
The service responsible for Honeypot's ElasticSearch data
Stars: ✭ 90 (-7.22%)
Mutual labels:  elasticsearch
Search Guard Docs
Official documentation for Search Guard, the Elasticsearch security suite
Stars: ✭ 92 (-5.15%)
Mutual labels:  elasticsearch
Zzdj dhcp
一个可以自动同步DHCP租用信息到数据库的微服务
Stars: ✭ 89 (-8.25%)
Mutual labels:  elasticsearch
Elkstack
The config files and docker-compose.yml files of Dockerized ELK Stack
Stars: ✭ 96 (-1.03%)
Mutual labels:  elasticsearch
Syliuselasticsearchplugin
Elasticsearch integration for Sylius apps.
Stars: ✭ 88 (-9.28%)
Mutual labels:  elasticsearch
Es Stats
ElasticSearch cluster metrics -> Graphite
Stars: ✭ 91 (-6.19%)
Mutual labels:  elasticsearch
Logisland
Scalable stream processing platform for advanced realtime analytics on top of Kafka and Spark. LogIsland also supports MQTT and Kafka Streams (Flink being in the roadmap). The platform does complex event processing and is suitable for time series analysis. A large set of valuable ready to use processors, data sources and sinks are available.
Stars: ✭ 97 (+0%)
Mutual labels:  elasticsearch
Logtrail
Kibana plugin to view, search & live tail log events
Stars: ✭ 1,343 (+1284.54%)
Mutual labels:  elasticsearch
Elasticsearch Hn
Index & Search Hacker News using Elasticsearch and the HN API
Stars: ✭ 92 (-5.15%)
Mutual labels:  elasticsearch

Build Status Codacy Badge "Docker Pulls Codacy Badge Analytics

A Demonstration of How to Use the Elasticsearch Java API

This repository demonstrates the use of Elasticsearch Java API via Java High Level REST Client. If you want to see the sample of the old version, please visit the oldVersion branch.

What you will learn in this repository?

  • How to use Java High Level REST Client
    • How to perform Administration operations
    • Index creation
    • Mapping settings
    • How to perform CRUD operations

Initialization Java High Level REST Client

    @Bean(destroyMethod = "close")
    public RestHighLevelClient getRestClient() {
        return new RestHighLevelClient(RestClient.builder(new HttpHost(props.getClients().getHostname(),
                props.getClients().getHttpPort(), props.getClients().getScheme())));
    }

Index creation and Shard, Replica settings with Java High Level REST Client

final GetIndexRequest request = new GetIndexRequest(props.getIndex().getName());
final boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);

if (!exists) {
    
  final CreateIndexRequest indexRequest = new CreateIndexRequest(props.getIndex().getName());
  indexRequest.settings(Settings.builder()
       .put("index.number_of_shards", props.getIndex().getShard())
       .put("index.number_of_replicas", props.getIndex().getReplica())
  );

  final CreateIndexResponse createIndexResponse = client.indices().create(indexRequest, RequestOptions.DEFAULT);
  if (createIndexResponse.isAcknowledged() && createIndexResponse.isShardsAcknowledged()) {
      log.info("{} index created successfully", props.getIndex().getName());
  } else {
      log.debug("Failed to create {} index", props.getIndex().getName());
  }

}

Mapping Settings

    
final PutMappingRequest mappingRequest = new PutMappingRequest(props.getIndex().getName());
final XContentBuilder builder = XContentFactory.jsonBuilder();
    
builder.startObject();
...
builder.endObject();        

mappingRequest.source(builder);
final AcknowledgedResponse putMappingResponse = client.indices().putMapping(mappingRequest, RequestOptions.DEFAULT);

if (putMappingResponse.isAcknowledged()) {
    log.info("Mapping of {} was successfully created", props.getIndex().getName());
} else {
    log.debug("Creating mapping of {} failed", props.getIndex().getName());
}

Using SearchSourceBuilder and showing search results

sourceBuilder.query(builder);
SearchRequest searchRequest = getSearchRequest();

SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
SearchHits hits = searchResponse.getHits();
SearchHit[] searchHits = hits.getHits();
for (SearchHit hit : searchHits) {
    Document doc = gson.fromJson(hit.getSourceAsString(), Document.class);
    doc.setId(hit.getId());
    result.add(doc);
}

Using Query String with Wildcard

result = getDocuments(QueryBuilders.queryStringQuery("*" + query.toLowerCase() + "*"));

Document deletion

final DeleteRequest deleteRequest = new DeleteRequest(props.getIndex().getName(), id);
client.delete(deleteRequest, RequestOptions.DEFAULT);

How to compile?

mvn clean install

The docker-maven-plugin needs Docker daemon, if you don't have it you should use -Dmaven.test.skip=true -Ddocker.skip parameters.

How to run?

mvn spring-boot:run

With this option, you should provide an elasticsearch server.

How to run with Docker?

sh run.sh

With this option, this application and an elasticsearch server run together.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].