Why does the documentation lack so many topics?

To be able to replace org.elasticsearch.* classes with co.elastic.* classes it would be very helpful to find a good documentation with a lot of examples. Why is it poorly possible to find any?
For instance, what are the equivalent classes to their counterparts in org.elasticsearch.*? Sometimes they sound similar but it's hardly possible to refactor the old code.
current example. How can I refactor this org.elasticsearch code to co.elastic code?

    public PartnerQueryBuilder withGeoBoundingBox(@NotNull GeoBoundariesDto geoBoundingBox) {
        geoBoundingBoxQuery = new GeoBoundingBoxQueryBuilder(FieldName.LOCATION)
            .setCornersOGC(
                new GeoPoint(geoBoundingBox.getBottomLeft().getLat(), geoBoundingBox.getBottomLeft().getLon()),
                new GeoPoint(geoBoundingBox.getTopRight().getLat(), geoBoundingBox.getTopRight().getLon())
            );

        return this;
    }

using the Java Api client (to avoid using the deprecated RestHighLevelClient.
other topic would be how to get SearchResponses from a org.elasticsearch.:MultiSearchRequest which needs to be converted to a co.elastic..MsearcxhRequest!??

Hi @du-it,

Welcome to the community! Thanks for your feedback on the examples. It is something we're aware of for the clients and actively building out. If there are particular examples you think would be useful to document raising a GitHub feature request issue could be helpful.

I've not written an example GeoBoundingBox query with the new Java client, but l think the Javadoc for GeoBoundingBoxQuery.Builder could help you get started.

Let us know if that does help, or if you get a solution working!

He Carly.

Thanks for your response. The javadoc didn't help much but I hope I found a solution. Maybe you could have a look at it!?
Legacy code:

import org.elasticsearch.index.query.GeoBoundingBoxQueryBuilder;

public class PartnerQueryBuilder {

    private GeoBoundingBoxQueryBuilder geoBoundingBoxQuery;

    public PartnerQueryBuilder withGeoBoundingBox(@NotNull GeoBoundariesDto geoBoundingBox) {
        geoBoundingBoxQuery = new GeoBoundingBoxQueryBuilder(FieldName.LOCATION)
            .setCornersOGC(
                new GeoPoint(geoBoundingBox.getBottomLeft().getLat(), geoBoundingBox.getBottomLeft().getLon()),
                new GeoPoint(geoBoundingBox.getTopRight().getLat(), geoBoundingBox.getTopRight().getLon())
            );

        return this;
    }
...
}

My attempt with co.elastic.* classes of elasticsearch-java 8.10.x:

import co.elastic.clients.elasticsearch._types.query_dsl.GeoBoundingBoxQuery;

public class PartnerQueryBuilder {

    private GeoBoundingBoxQuery.Builder geoBoundingBoxQuery;

    public PartnerQueryBuilder withGeoBoundingBox(@NotNull GeoBoundariesDto geoBoundingBox) {
        GeoBounds geoBounds = new GeoBounds.Builder()
            .trbl(b -> {
                b.topRight(new GeoLocation.Builder().latlon(geoBoundingBox.getTopRight().latlon()).build()).build();
                b.bottomLeft(new GeoLocation.Builder().latlon(geoBoundingBox.getBottomLeft().latlon()).build()).build();
                return b;
            }).build();

        geoBoundingBoxQuery = new GeoBoundingBoxQuery.Builder().boundingBox(geoBounds);

        return this;
    }
...
}
1 Like

Thanks for coming back with a solution @du-it! The code looks good to me. I assume it's working for you as expected?

I can't answer this question right now because there are tons of changes I have to do to make the code compilable at all.

1 Like

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