springspring-bootmavenelasticsearchspring-data-elasticsearch

Spring data elasticsearch repository.count() returns "Current token (VALUE_NUMBER_INT) not of boolean type"


I'm in the process of upgrading a fairly old app from spring boot 2.0.2 to the latest one.
An interim goal was to update to the latest version 2 (2.7.18)
So this is probably a dependency version problem more than anything else, because before update it worked flawlessly.

Now, what the problem is?

[type=json_parse_exception, reason=Current token (VALUE_NUMBER_INT) not of boolean type

full exception

RestStatusException{status=500} org.springframework.data.elasticsearch.RestStatusException: Elasticsearch exception [type=json_parse_exception, reason=Current token (VALUE_NUMBER_INT) not of boolean type
 at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@79b99ce2; line: 1, column: 137]]; nested exception is ElasticsearchStatusException[Elasticsearch exception [type=json_parse_exception, reason=Current token (VALUE_NUMBER_INT) not of boolean type

The code that throws is this (simplified):

@Repository
public interface MetadataWithIdRepository extends ElasticsearchRepository<MetadataWithId, String>
(...)
private final MetadataWithIdRepository repository
(...)
repository.count() //throws here

Helpful facts:

  1. The problem shows up in integration tests when I spin up an embedded elastic container
  1. used versions
    | spring boot | spring | spring-cloud | boot-data-elastic | elastic-lib | elastic-instance | active mq
old | 2.0.2       | 5.0.6  | Finchley.SR1 | 3.0.7             | 5.6.9       | 6.5.1            |
new | 2.7.18      | 5.3.31 | 2021.0.3     | 4.4.18            | 7.17.15     | 6.5.1            | 5.16.7
  1. When I stop my tests with a debugger and query my index I get this:
GET localhost:56229/_cat/indices
yellow open document-domain FQBoF0knRWa-4CVcgAKWsw 5 1 0 0 1.1kb 1.1kb
GET localhost:56229/document-domain/_search
{
    "took": 39,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 0,
        "max_score": null,
        "hits": []
    }
}

So the instance is up and running.

I tried debugging this in 10 different ways, but every time I hit a dead end.

The only somewhat similar mention of this in english-speaking internets I could find is this, but it does not help

I know that's it's a weird problem and that I have no reproducible example, but maybe someone has seem something similar. I'll be grateful for any hints on what to do with that.


Solution

  • elastic library 7.x is not backwards compatible with elastic service 6.x
    upgrading the service will make the problem go away