QueryBuilders.moreLikeThis() bug in 7.16 Java API?

I'm trying to create a SearchRequest with a MoreLikeThisQuery like so:

        JsonData jsonDocument = JsonData.of(document);
        LikeDocument likeDocument = new LikeDocument.Builder().doc(jsonDocument).build();
        MoreLikeThisQuery moreLikeThisQuery = QueryBuilders.moreLikeThis()
                .like(new Like.Builder().document(likeDocument).build())
                .build();
        SearchRequest moreLikeThis = new SearchRequest.Builder()
                .index("my-index")
                .query(moreLikeThisQuery)
                .build();

But I'm getting this compile error on the second to last line of that:

Cannot resolve method 'query(co.elastic.clients.elasticsearch._types.query_dsl.MoreLikeThisQuery)'

What am I doing wrong?

Thanks!

The code should have been this:

        SearchRequest moreLikeThis = new SearchRequest.Builder()
                .index("my-index")
                .query(new Query.Builder().moreLikeThis(moreLikeThisQuery).build())
                .build();

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.