ElasticsearchStatusException contains unrecognized parameter: [ccs_minimize_roundtrips]]] - elasticsearch

I am trying to do a simple search on ElasticSearch server and getting teh following error
ElasticsearchStatusException[Elasticsearch exception [type=illegal_argument_exception, reason=request [/recordlist1/_search] contains unrecognized parameter: [ccs_minimize_roundtrips]]]
The query String :
{"query":{"match_all":{"boost":1.0}}}
I am using :
elasticsearch-rest-high-level-client (maven artifact)
SearchRequest searchRequest = new SearchRequest(INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchAllQuery());
searchRequest.source(searchSourceBuilder);
try
{
System.out.print(searchRequest.source());
SearchResponse response = getConnection().search(searchRequest,RequestOptions.DEFAULT);
SearchHit[] results=response.getHits().getHits();
for(SearchHit hit : results)
{
String sourceAsString = hit.getSourceAsString();
System.out.println( gson.fromJson(sourceAsString, Record.class).year);
}
}
catch(ElasticsearchException e)
{
e.getDetailedMessage();
e.printStackTrace();
}
catch (java.io.IOException ex)
{
ex.getLocalizedMessage();
ex.printStackTrace();
}

This usually occurs on porting from elastic-search version 6.X.X to 7.X.X.
You should reduce the elastic-search version to 6.7.1 and try running it.
Since you are using maven you should make sure your dependencies should be like:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.7.1</version>
</dependency>

I ran into this same issue when i had by mistake my 6.5 cluster still running while using the 7.2 API. Once I started up my 7.2 cluster the exception went away.

Problem here is the movement of version, probably you were using elastic search 6.x.x and now using 7.x.x
You can definitely solve this by having your elastic search server of 7.x.x.
Elasticsearch 6.x.x used to have type of document
(where you could give type to your documents)
but Elasticsearch 7.x.x onwards it has no type or
default type _doc, so you need to have _doc as your type
while creating mapping.

Maybe you can find this from stackTrace of exception:
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://127.0.0.1:9200], URI [/recordlist1/_search?rest_total_hits_as_int=true&typed_keys=true&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=true&ignore_throttled=false&search_type=query_then_fetch&batched_reduce_size=512], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [/_search] contains unrecognized parameters: [ignore_throttled], [rest_total_hits_as_int]"}],"type":"illegal_argument_exception","reason":"request [/_search] contains unrecognized parameters: [ignore_throttled], [rest_total_hits_as_int]"},"status":400}
So, You can try this GET method by curl, which come to the same error message.
curl -XGET http://127.0.0.1:9200/recordlist1/_search?rest_total_hits_as_int=true&typed_keys=true&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=true&ignore_throttled=false&search_type=query_then_fetch&batched_reduce_size=512
I've tried delete 'rest_total_hits_as_int=true' ... Case Closed.
You should check your es-server's version by elasticsearch -V and client’s version in maven.
In high-level client, they add rest_total_hits_as_int=true by default, and I find no access to set it to false.
you can refer to
org.elasticsearch.client.RequestConverters#addSearchRequestParams Line:395 <v6.8.10>
I had no other choice but matching client to match server.
Why it's so Exciting ?
ehn... after all, it is "High Level".

Related

Java High Level Rest Client - Mutli Search API Not working with Elasticsearch 8.3.2

Im using Java High level rest client version 7.17.5. Im applying the same but it doesnt work. Please find the below code
SearchSourceBuilder metaDataSearch = new SearchSourceBuilder();
org.elasticsearch.action.search.SearchRequest metaSearch = new org.elasticsearch.action.search.SearchRequest().source(metaDataSearch).indices(indexName);
SearchSourceBuilder keywordExactRequestBuilder = new SearchSourceBuilder().size(10);
keywordExactRequestBuilder.query(QueryBuilders.matchAllQuery());
org.elasticsearch.action.search.SearchRequest keywordExactRequestSearch = new org.elasticsearch.action.search.SearchRequest().source(keywordExactRequestBuilder).indices(indexName);
MultiSearchRequest multiSearchRequest = new MultiSearchRequest()
.add(metaSearch)
.add(keywordExactRequestSearch);
MultiSearchResponse multiSearchResponse = null;
try {
multiSearchResponse = elasticClient.msearch(multiSearchRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
e.printStackTrace();
}
Im facing the below exception
org.jboss.resteasy.spi.UnhandledException: ElasticsearchStatusException[Elasticsearch exception [type=illegal_argument_exception, reason=key [types] is not supported in the metadata section]]
.......
Caused by:
ElasticsearchStatusException[Elasticsearch exception [type=illegal_argument_exception, reason=key [types] is not supported in the metadata section]]
......
Im enabled API compatibility mode. Im using elasticsearch version 8.3.2
Thanks

How can I fix the error "The [standard] token filter has been removed"?

I am trying to upgrade a project from ElasticSearch 2.3 with NEST version 2.5.8 to ElasticSearch 7.9 with NEST 7.11.1. When I try to create the index I get the error:
# OriginalException: Elasticsearch.Net.ElasticsearchClientException: The remote server returned an error: (400) Bad Request.. Call: Status code 400 from: PUT /partsearch.01. ServerError: Type: illegal_argument_exception Reason: "failed to build synonyms" CausedBy: "Type: parse_exception Reason: "Invalid synonym rule at line 1" CausedBy: "Type: illegal_argument_exception Reason: "The [standard] token filter has been removed."""
The code that is attempting to create the index when this error occurs is:
protected internal CreateIndexResponse CreateIndex(string name)
{
var indicesOperationResponse = this.elasticClientProxy.CreateIndex(
name, c => c
.Settings(
s => s
.NumberOfReplicas(this.numberOfReplicas)
.NumberOfShards(this.numberOfShards)
.Setting("index.max_result_window", this.maxResultWindow)
.Analysis(
ad => ad
.CharFilters(this.RegisterCharFilters)
.Tokenizers(this.RegisterTokenizers)
.TokenFilters(this.RegisterTokenFilters)
.Analyzers(this.RegisterAnalyzers)))
.Map<T>(this.Map)
.Map<IndexMetaData>(this.MapIndexMetaData));
return indicesOperationResponse;
}
The implementation of the RegisterTokenFilters is:
protected internal override TokenFiltersDescriptor RegisterTokenFilters(TokenFiltersDescriptor descriptor)
{
return descriptor.UserDefined(TokenFilter.NormalizeNumberSeparator.DisplayName, TokenFilter.NormalizeNumberSeparator.Filter)
.UserDefined(TokenFilter.CustomStopWordFilter.DisplayName, TokenFilter.CustomStopWordFilter.Filter)
.UserDefined(TokenFilter.StripNumberUnit.DisplayName, TokenFilter.StripNumberUnit.Filter)
.UserDefined(TokenFilter.StripEndingPunctuation.DisplayName, TokenFilter.StripEndingPunctuation.Filter)
.UserDefined(TokenFilter.StripCommaFromNumber.DisplayName, TokenFilter.StripCommaFromNumber.Filter)
.UserDefined(TokenFilter.EnglishStemmer.DisplayName, TokenFilter.EnglishStemmer.Filter)
.UserDefined(TokenFilter.EnglishPossessiveStemmer.DisplayName, TokenFilter.EnglishPossessiveStemmer.Filter)
.UserDefined(TokenFilter.PatternFilter.DisplayName, TokenFilter.PatternFilter.Filter)
.UserDefined(TokenFilter.SynonymFilter.DisplayName, TokenFilter.SynonymFilter.Filter)
.UserDefined(TokenFilter.StripLeadingCharNoise.DisplayName, TokenFilter.StripLeadingCharNoise.Filter)
.UserDefined(TokenFilter.NumericSynonymFilter.DisplayName, TokenFilter.NumericSynonymFilter.Filter)
.UserDefined(TokenFilter.StemmerExclusionFilter.DisplayName, TokenFilter.StemmerExclusionFilter.Filter)
.UserDefined(TokenFilter.AsciiFoldingTokenFilter.DisplayName, TokenFilter.AsciiFoldingTokenFilter.Filter)
.UserDefined(TokenFilter.DashWordsSynonymFilter.DisplayName, TokenFilter.DashWordsSynonymFilter.Filter)
.UserDefined(TokenFilter.DashSplitTokenFilter.DisplayName, TokenFilter.DashSplitTokenFilter.Filter);
}
I wanted to find and remove the Standard token filter based on answers I found to similar errors but I don't see it being used here.
How can I troubleshoot and resolve this issue?
The method RegisterAnalyzers made a call that led to this code:
private static AnalyzerBase CustomDescriptionAnalyzer()
{
var customAnalyzer = new CustomAnalyzer();
customAnalyzer.CharFilter = new List<string>
{
CharacterFilter.HtmlStrip.DisplayName,
CharacterFilter.UniCodeFilter.DisplayName
};
customAnalyzer.Tokenizer = Tokenizer.DescriptionTokenizer.DisplayName;
customAnalyzer.Filter = new List<string>
{
TokenFilter.Standard.DisplayName,
TokenFilter.Lowercase.DisplayName,
TokenFilter.StripLeadingCharNoise.DisplayName,
TokenFilter.PatternFilter.DisplayName,
TokenFilter.StripLeadingCharNoise.DisplayName,
TokenFilter.NormalizeNumberSeparator.DisplayName,
I removed the line TokenFilter.Standard.DisplayName from the customerAnalyzer.Filter list and now I don't get the error Type: parse_exception Reason: "Invalid synonym rule at line 1" CausedBy: "Type: illegal_argument_exception Reason: "The [standard] token filter has been removed
See also
Breaking changes in 7.0
The [standard] token filter has been removed #175
Standard token filter removal causes exceptions after upgrade #50734

DeleteByQueryPlugin cannot be resolved to a type && FRAMELESS_COMPILE_ENABLED : NoSuchFieldError

Iam having the following error when i upgraded the elasticsearch to 2.3.2 and used delete-by-query plugin . The code is something like this
Settings settings = Settings.settingsBuilder().build();
TransportClient transportClient = null;
for (String node : nodes.trim().split(",")) {
String[] parts = node.split(":");
transportClient=TransportClient.builder().settings(settings)
.addPlugin(DeleteByQueryPlugin.class).build();
transportClient = transportClient.addTransportAddress(
new InetSocketTransportAddress(
InetAddress.getByName(parts[0]),Integer.valueOf(parts[1])));
And the Error:
play.exceptions.CompilationException: DeleteByQueryPlugin cannot be resolved to a type
at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:246)
at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:676)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:520)
at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:282)
at play.classloading.ApplicationClasses$ApplicationClass.compile(ApplicationClasses.java:281)
at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:166)
at play.classloading.ApplicationClassloader.loadClass(ApplicationClassloader.java:84)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at play.plugins.PluginCollection.loadPlugins(PluginCollection.java:168)
at play.Play.init(Play.java:303)
at play.server.Server.main(Server.java:162)
Exception in thread "main" java.lang.NoSuchFieldError: FRAMELESS_COMPILE_ENABLED
at play.modules.sass.Engine.<init>(Engine.java:44)
at play.modules.sass.Plugin.onLoad(Plugin.java:15)
at play.plugins.PluginCollection.initializePlugin(PluginCollection.java:251)
at play.plugins.PluginCollection.loadPlugins(PluginCollection.java:185)
at play.Play.init(Play.java:303)
at play.server.Server.main(Server.java:162)
Can any one give me any pointers how can i solve this error

path.home is not configured in elasticsearch

Exception in thread "main" java.lang.IllegalStateException: path.home is not configured
at org.elasticsearch.env.Environment.(Environment.java:101)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:81)
at org.elasticsearch.node.Node.(Node.java:128)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)
at JavaAPIMain.main(JavaAPIMain.java:43)
//adding document to elasticsearch using java
Node node = nodeBuilder().clusterName("myapplication").node();
Client client = node.client();
client.prepareIndex("kodcucom", "article", "1")
.setSource(putJsonDocument("ElasticSearch: Java",
"ElasticSeach provides Java API, thus it executes all operations " +
"asynchronously by using client object..",
new Date(),
new String[]{"elasticsearch"},
"Hüseyin Akdoğan")).execute().actionGet();
How about trying this one:
NodeBuilder.nodeBuilder()
.settings(Settings.builder()
.put("path.home", "/path/to/elasticsearch/home/dir")
.node();
Credits: https://github.com/elastic/elasticsearch/issues/15325
Always ask Google about your error message first. There are more than 5k results for your problem.
if you are using intellij or eclipse,
edit configuration and add the below line in your VMoptions
-Des.path.home={dropwizard installation directory}
for example in my mac
-Des.path.home=/Users/supreeth.vp/elasticsearch-2.3.4/bin

Elasticsearch 2.0: how to delete by query in Java

I am trying to upgrade to ES 2.0. I have downloaed ES 2.0 and installed it on my Windows machine.
In my pom.xml, I have the following:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.0.0-rc1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>delete-by-query</artifactId>
<version>2.0.0-rc1</version>
</dependency>
In my Java code, I did delete by query in the following way when using ES 1.7.3:
StringBuilder b = new StringBuilder("");
b.append("{");
b.append(" \"query\": {");
b.append(" \"term\": {");
b.append(" \"category\": " + category_value );
b.append(" }");
b.append(" }");
b.append("}");
client = getClient();
DeleteByQueryResponse response = client.prepareDeleteByQuery("myindex")
.setTypes("mydocytype")
.setSource(b.toString())
.execute()
.actionGet();
I am hoping to replace this:
DeleteByQueryResponse response = client.prepareDeleteByQuery("myindex")
.setTypes("mydocytype")
.setSource(b.toString())
.execute()
.actionGet();
with ES 2.0 way. Googled but failed to find an example for it. The online API documentation seems too abstract to me. How can I do it?
Another question: Do I have to install delete-by-query plugin in Elasticsearch server?
Thanks for any pointer!
UPDATE
I followed Max's suggestion, and here is what I have now:
First, when create the client, make settings look like the following:
Settings settings = Settings.settingsBuilder()
.put("cluster.name", "mycluster")
.put("plugin.types", DeleteByQueryPlugin.class.getName())
.build();
Second, at the place doing delete-by-query:
DeleteByQueryResponse rsp = new DeleteByQueryRequestBuilder(client, DeleteByQueryAction.INSTANCE)
.setIndices("myindex")
.setTypes("mydoctype")
.setSource(b.toString())
.execute()
.actionGet();
I also installed delete by query plugin by running the following in the root directory of ES:
bin\plugin install delete-by-query
I get errors if I do not install this plugin.
After all these steps, ES related parts work just fine.
plugin.types have been deprecated in ES 2.1.0 (source). So the accepted solution will result in a NullPointerException.
The solution is to use the addPlugin method:
Client client = TransportClient.builder().settings(settings())
.addPlugin(DeleteByQueryPlugin.class)
.build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host",9300));
I believe you can use this:
DeleteByQueryResponse rsp = new DeleteByQueryRequestBuilder(client, DeleteByQueryAction.INSTANCE)
.setTypes("mydocytype")
.setSource(b.toString())
.execute()
.actionGet();
You have to add plugin type to your settings:
Settings settings = Settings.settingsBuilder()
.put("plugin.types", DeleteByQueryPlugin.class.getName())
If you have remote server you have to install the plugin.
From Elastic 5 in onwards...
final BulkIndexByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(super.transportClient)
.filter(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("_type", "MY_TYPE")) // Trick to define and ensure the type.
.must(QueryBuilders.termQuery("...", "...")))
.source("MY_INDEX")
.get();
return response.getDeleted() > 0;
Oficial documentation
firstly:
add elasticsearch-2.3.3/plugins/delete-by-query/delete-by-query-2.3.3.jar to build path.
then:
Client client = TransportClient.builder().settings(settings)
.addPlugin(DeleteByQueryPlugin.class)
.build()
.addTransportAddress(new InetSocketTransportAddress(
InetAddress.getByName("192.168.0.224"), 9300));

Resources