I can delete a document by passing the index name , type and id like this-
DeleteRequest deleteRequest = new DeleteRequest(data.getIndexName(),data.getType(),data.getUniqueId());
DeleteResponse deleteResponse = client.delete(deleteRequest);
But when I am trying to delete an index by giving the index name only like below- (According to this document)
DeleteRequest deleteRequest = new DeleteRequest(allData.getIndexName());
DeleteResponse deleteResponse = client.delete(deleteRequest);
getting-
org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: type is missing;2: id is missing;
I have tried another way like this (reference)
DeleteIndexRequest request = new DeleteIndexRequest(allData.getIndexName());
AcknowledgedResponse deleteIndexResponse = client.indices().delete(request, RequestOptions.DEFAULT);
getting:
java.lang.NoSuchMethodError:
at org.elasticsearch.client.IndicesClient.delete(IndicesClient.java:93) ~[elasticsearch-rest-high-level-client-6.5.4.jar:6.4.3]
I am using this dependency:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.5.4</version>
</dependency>
mvn dependency:tree
[INFO] \- org.elasticsearch.client:elasticsearch-rest-high-level-
client:jar:6.5.4:compile
[INFO] +- org.elasticsearch:elasticsearch:jar:6.4.3:compile
[INFO] | +- org.elasticsearch:elasticsearch-core:jar:6.4.3:compile
[INFO] | +- org.elasticsearch:elasticsearch-secure-
sm:jar:6.4.3:compile
[INFO] | +- org.elasticsearch:elasticsearch-x-
content:jar:6.4.3:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-
dataformat-smile:jar:2.9.8:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-
dataformat-yaml:jar:2.9.8:compile
[INFO] | | \- com.fasterxml.jackson.dataformat:jackson-
dataformat-cbor:jar:2.9.8:compile
[INFO] | +- org.apache.lucene:lucene-core:jar:7.4.0:compile
[INFO] | +- org.apache.lucene:lucene-analyzers-
common:jar:7.4.0:compile
[INFO] | +- org.apache.lucene:lucene-backward-
codecs:jar:7.4.0:compile
[INFO] | +- org.apache.lucene:lucene-grouping:jar:7.4.0:compile
[INFO] | +- org.apache.lucene:lucene-highlighter:jar:7.4.0:compile
[INFO] | +- org.apache.lucene:lucene-join:jar:7.4.0:compile
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>search-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>search-service</name>
<description>Demo project for search-service</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.7.0</version><!--$NO-MVN-MAN-VER$-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
delete
method already. – Syndromeorg.elasticsearch
) is being used. This should be 6.5.4 or above. – Poultryman<elasticsearch.version>6.5.4</elasticsearch.version>
and add the elastic dependency as<dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>${elasticsearch.version}</version> </dependency>
– Poultryman