GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - giangithud/ElasticSearch: :globe_with_meridians: This application illustrates and demonstrates use of ElasticSearch Java API in the backend

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

17 Commits
17 Commits

Folders and files

NameName
Last commit message
Last commit date
image
image
 
 
src
src
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
Dockerfile
Dockerfile
 
 
ElasticSearch.iml
ElasticSearch.iml
 
 
README.md
README.md
 
 
docker-compose.yml
docker-compose.yml
 
 
down.sh
down.sh
 
 
pom.xml
pom.xml
 
 
run.sh
run.sh
 
 

Repository files navigation

Build Status "Docker Pulls Coverage Status Analytics

Illustration and demonstration use of ElasticSearch

This repository illustrates and demonstrates the use of ElasticSearch Java API with most up to date version of ElasticSearch which provides Java High Level REST Client. If you want to see the sample of the old version, please visit the oldVersion branch.

How to Use Java High Level REST Client in the backend?

The client added in version 6.0.0-beta1 and it works on top of the Java low level rest client.

Initialization

RetHighLevelClient(RestClient.builder(new HttpHost(props.getRestClient().getHostname(),
                props.getRestClient().getPort(), props.getRestClient().getScheme())));

Creating an index

IndexRequest request = new IndexRequest(props.getIndex().getName(), props.getIndex().getType());
request.source(gson.toJson(document), XContentType.JSON);
IndexResponse response = client.index(request);

Using SearchSourceBuilder and showing search results

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

SearchResponse searchResponse = client.search(searchRequest);
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 wildcard query

QueryBuilders.wildcardQuery("_all", "*" + query.toLowerCase() + "*")

Deleting a document

DeleteRequest deleteRequest = new DeleteRequest(props.getIndex().getName(), props.getIndex().getType(), id);

How to run?

mvn spring-boot:run

How to run with Docker?

docker run -d --name elasticsearch -p 8080:8080 hakdogan/elasticsearch:newVersion

About

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

Resources

Readme
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.