Skip to content

spring-data-elasticsearch:4.4.10 IndicesBoost error #2598

Closed
@freedally

Description

@freedally

spring-data-elasticsearch:4.4.10

    List<IndexBoost> indexBoosts = new ArrayList<>();
    indexBoosts.add(new IndexBoost(IndexConst.INDEX_NAME_1, 2));
    indexBoosts.add(new IndexBoost(IndexConst.INDEX_NAME_2, 1));


    Pageable pageable = PageRequest.of(0, 10);

    NativeQuery nativeQuery = NativeQuery.builder()
            .withIndicesBoost(indexBoosts)
            .withQuery(query)
            .withPageable(pageable).build();

    SearchHits<EntityAsMap> searchHits = elasticsearchTemplate.search(nativeQuery, EntityAsMap.class, IndexCoordinates.of(IndexConst.INDEX_NAME_1, IndexConst.INDEX_NAME_2));

Received exception

Caused by: co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/search] failed: [parsing_exception] Expected [END_OBJECT] in [indices_boost] but found [FIELD_NAME]
	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:313)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:153)
	at co.elastic.clients.elasticsearch.ElasticsearchClient.search(ElasticsearchClient.java:1754)
	at org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate.lambda$search$14(ElasticsearchTemplate.java:312)
	at org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate.execute(ElasticsearchTemplate.java:514)
	... 71 more

Is my method incorrect?

There seems to be an error here:org.springframework.data.elasticsearch.client.elc.RequestConverter

// line 1206
if (!isEmpty(query.getIndicesBoost())) {
    Map<String, Double> boosts = new LinkedHashMap<>();
    query.getIndicesBoost().forEach(indexBoost -> {
        boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost());
    });
    // noinspection unchecked
    builder.indicesBoost(boosts);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions