how to add url parameters in ElasticSearch DeleteByQuery java API? - elasticsearch

I am using Elasticsearch version 2.3.1
I want to implement Deletebyquery of ES in java
Es have docs for that https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
This doc stats that In deletebyquery request we can have a params like wait_for_completion=false , wait_for_active_shards , etc
This is fine for curl request, But my problem is I want to implement the same using java api, with that wait_for_completion flag set.
My java code for Deletebyquery in java
DeleteByQueryRequestBuilder deleteRequest = DeleteByQueryRequestBuilder(esType, DeleteByQueryAction.INSTANCE)
.setIndices(index)
.setTypes(type);
deleteRequest.setQuery(boolQuery);
DeleteByQueryResponse resp = deleteRequest.get();
I want to know where I can add wait_for_completion flag in java api request, kindly advice me. Thanks

The document link provided in the OP is for the latest version of elasticsearch.
Elasticsearch 2.3 supports DeleteByQuery only via a plugin.
The external plugin does not have wait_for_completion option.
The feature was re-introduced in 5.x.

Related

Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true [JAVA]

We have a java application (spring boot + hibernate search + elastic search).
Application is working fine on elastic search version 6.8
Recently, we have created a new cluster in aws with version 7.10.2 and updated elastic search endpoint in my java application.
After updating the elastic search endpoint I am getting error Can't update put mapping Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true and due to this unable to start the server.
I am not sure where to set include_type_name=true because all the indexes gets created automatically with #Indexed.
Can someone please let us know how can we fix this issue ?
Thanks #yrodiere for your response.
I tried to upgrade below dependencies version but unfortunately not able to fix it.
Previous Version:
compile 'org.hibernate:hibernate-search-orm:5.9.3.Final'
compile 'org.hibernate:hibernate-search-elasticsearch:5.9.3.Final'
compile 'org.hibernate:hibernate-search-elasticsearch-aws:5.9.3.Final'
Updated version :
compile 'org.hibernate:hibernate-search-orm:5.9.3.Final
compile 'org.hibernate.search:hibernate-search-backend-elasticsearch:6.1.1.Final'
compile 'org.hibernate.search:hibernate-search-backend-elasticsearch-aws:6.1.1.Final'
Note: If I downgrade this org.hibernate:hibernate-search-orm:5.9.3.Final then getting CE
am i missing something?
You're probably using Hibernate Search 5.x. In Hibernate Search 5.x, the Elasticsearch integration was experimental and only compatible with Elasticsearch up to version 5.6.
The fact that your application was working fine with Elasticsearch 6.8 was pure luck: Hibernate Search 5.x was never intended to work with Elasticsearch 6+.
To upgrade to a more recent version of Elasticsearch, you must upgrade to Hibernate Search 6.0 (or later). The API is different, but there is a very detailed migration guide, and at least you will get production-ready (non-experimental) Elasticsearch integration (plus tons of improvements).
Note that Hibernate Search 6.x also requires upgrading to Hibernate ORM 5.4; see this compatibility matrix.

How to change elasticsearch version in reactive spring data elastic search api?

spring data elasticsearch uses 7.x client version and my production elasticsearch version is 6.4.2. So I changed the version and got the following exception. How to safely change version in spring data es?
Repopsitory: https://github.com/Yungdi/spring-data-reactive-elasticsearch
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.<init>(ReactiveElasticsearchTemplate.java:108)
The following method did not exist:
org.elasticsearch.action.support.IndicesOptions.strictExpandOpenAndForbidClosedIgnoreThrottled()Lorg/elasticsearch/action/support/IndicesOptions;
The method's class, org.elasticsearch.action.support.IndicesOptions, is available from the following locations:
jar:file:/Users/we/DevEnv/gradle-6.4.1/caches/modules-2/files-2.1/org.elasticsearch/elasticsearch/6.4.2/29a4003b7e28ae8d8896041e2e16caa7c4272ee3/elasticsearch-6.4.2.jar!/org/elasticsearch/action/support/IndicesOptions.class
The class hierarchy was loaded from the following locations:
org.elasticsearch.action.support.IndicesOptions: file:/Users/we/DevEnv/gradle-6.4.1/caches/modules-2/files-2.1/org.elasticsearch/elasticsearch/6.4.2/29a4003b7e28ae8d8896041e2e16caa7c4272ee3/elasticsearch-6.4.2.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.action.support.IndicesOptions
You can’t use a Elasticsearch 6 cluster with Spring Data Elasticsearch 4 which uses Elasticsearch 7 libraries. The Elasticsearch REST API that is used had breaking changes between version 6 and 7.
You can try to use Spring Data Elasticsearch 3.2.x which targets 6.8; I currently don’t know if there were breaking changes between Elasticsearch 6.4 and 6.8, you’ll have to try it.

Couchbase plugin for ElasticSearch deprecated?

I was reading https://www.elastic.co/blog/deprecating-rivers which stats that ES rivers (plugin) are getting deprecated. i.e. any plugin directly integrated with ElasticSearch server will no longer work beyond ES 3.x onwards.
Couchbase plugin is one of those kind.
I searched all the documents of couchbase plugin at http://developer.couchbase.com/documentation/server/4.5/connectors/elasticsearch-2.1/elastic-intro.html but could not find if they are using deprecated way or not?
Does anyone know? Should we keep using couchbase plugin or should start planning to write data directly to ES using our application.
We have couchbase data getting replicated to ES using couchbase plugin and XDCR.
I'm the maintainer of the Couchbase ES transport plugin. As Roi mention in his answer, the plugin doesn't use rivers, so it won't be deprecated. It currently supports any version of ES from 1.3 to 2.x, and I'm working on adding support for 5.x. It's taking a bit longer, because ES 5.x broke some configuration sharing features in unexpected ways.
I'd suggest always looking at our github repo for the latest plugin releases:
https://github.com/couchbaselabs/elasticsearch-transport-couchbase
The Couchbase plugin is not using Rivers, there is another River plugin which is not longer valid.
take a look here: https://github.com/couchbaselabs/elasticsearch-transport-couchbase

ElasticSearch - Index a large file using Java API

We have a requirement wherein we have to use ElasticSearch for performing full text search. We have a Spring based application and for integration with ES we can use either Java API of Elastic Search or Spring Data for ElasticSearch.
The input will be of a file type having size around 5MB.
I went through examples for both ES Java API and SpringData, they do have
tutorials available for inserting a JSON document.
But any help with regards to using File as an input to create documents/index is not available.
I am newbie with Elastic Search, any guidance/help on this will be much appreciated.
EDIT:
I could see that there is a Ingest Attachment Processor plugin available in ES (https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest-attachment.html).
Can anybody point me to a sample CURL request to use this plugin or any Java code to use this plugin
1.You may use Elasticsearch mapper attachments plugin. This plugin uses Apache Tika to ingest almost any well known type of document and make it searchable by Elasticsearch.
https://www.elastic.co/guide/en/elasticsearch/plugins/2.3/mapper-attachments.html
2.You can use Apache Tika to extract useful content from file and use elasticsearch Bulk Indexing api to index to ES
Hope that helps

How to know the recommended version elastic search of the logstash

I am an newbie to logstash, when I studied
logstash sample. I noticed that it said
Each release of Logstash has a recommended version of Elasticsearch you
should use.
But I failed to find it. I didn't see the release notes of logstash. For example, the logstash I used is 1.5.0, how to know which version elastic search I should use. In the sample above, it said I could use 1.5.1 version.
All Logstash version including and after 1.4.2 can use any ElasticSearch version above 1.x
It is suggested to use ElasticSearch above 1.1.1 as there was a small vulnerability which has since been patched in later versions.
Using 1.5.0 and 1.5.1 will be perfectly fine.
You cand find some notes regarding the recommended ElasticSearch version in Logstash web documentation > Output plugins > ElasticSearch. Here is the link for the current logstash version:
https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html
For instance, if you want to know about the recommended Elasticsearch version for Logstash 1.4.2, you can visit the old documentation, here:
http://logstash.net/docs/1.4.2/outputs/elasticsearch
Try changing the version from the URL to get specific details for this version. For instance, for Logstash 1.3.2 you can use:
http://logstash.net/docs/1.3.2/outputs/elasticsearch
In each of these documentation references you'll find a section "VERSION NOTE" regarding the recommended ElasticSearch version.

Resources