New Java API migration

Hi,
We are trying to migrate to the new Java client, and we obviously have difficulties in finding our way in the current (light) documentation. Can you help me with the following?

            // HLRC code
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.fetchSource(null, "foo")
                    .sort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC)
                    .query(QueryBuilders.matchAllQuery())
                    .size(100);
            SearchRequest request = new SearchRequest("myindex");
            request.source(searchSourceBuilder);

migrates to?

            SearchRequest search = SearchRequest.of(r -> r
                    .index("myindex")
                    .source(b -> b.fetch(true).filter(c -> c.excludes("foo")))
                    .sort(b -> b.field(c -> c.order(SortOrder.Asc)))
                    .query(b -> b.matchAll(c -> c.queryName("matchAllQuery")))
            );

The line b.fetch(true).filter(c -> c.excludes("foo")) does not compile though, and I'm not sure for the sort condition (how to translate the FieldSortBuilder.DOC_FIELD_NAME item?)

Other issue, with the delete API:
client.delete(b -> b.index(index).id(ref));
How do I know the result of the request? In the HLRC, we could check for response.status().equals(RestStatus.NOT_FOUND) for instance, but how to that now?

Cheers,

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