14

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();
        }
Lamanus
  • 12,898
  • 4
  • 21
  • 47
meyy
  • 141
  • 1
  • 1
  • 3
  • 2
    What version of ES are you running and what version of the ES client are you using? It seems you're mixing version 7 vs another one, but unsure which one. – Val Apr 10 '19 at 05:38

4 Answers4

8

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>
YetAnotherBot
  • 1,937
  • 2
  • 25
  • 32
  • 7
    This is not a valid solution when you really want to work with ElasticSearch 7.X.X – Sulejmani Jul 23 '19 at 14:06
  • @Sulejmani That's true. This just points out a possible scenario. I fixed it by reducing the version. This will work especially for people unnecessarily jumping to 7.X.X – YetAnotherBot Jul 24 '19 at 06:58
  • How do I upgrade from 6.1.1 to 7.3.0 then? The rolling upgrade is supported from 5.6 -> 6.8. Then 6.8 -> 7.3. Do I upgrade ES first then REST package? Or vice versa? Note: 6.1.1 has the stupid bug where _doc cannot be used as "type"; therefore, I am currently using "doc" as the "type". – user2833162 Aug 08 '19 at 21:44
  • Yeah. Moving from = v7.X.X is kind of tough. This is because there are many breaking changes from 6.x.x to 7.x.x Hopefully your application is layered and has some kind of dependency injection. This way you could slowly start converting some APIs like search first, then update, etc. – YetAnotherBot Aug 09 '19 at 05:31
  • Also, afair 'type' is not supported after 6.x.x – YetAnotherBot Aug 09 '19 at 05:37
  • 1
    The question is to keep your client's version compatible with the elastic search version, in my case I was using version 7.xx on the client to run the query and the error happened, as I cannot change my client I upgraded of elasticsearch. – phdias Aug 13 '20 at 18:21
2

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.

denov
  • 11,180
  • 2
  • 27
  • 43
2

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.
Anshul Sharma
  • 1,018
  • 3
  • 17
  • 39
1

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".

Debuff
  • 41
  • 3