Java SDK 3.4.1 FTS with geopoint index type problem

Hi all!

I’m using Java 11 with JDK version 3.4.1
Couchbase: Enterprise Edition 7.1.3 build 3479

I’m trying to run a search query with FTS geopoint type index. When I use the same query at the UI the results are returned but when I try to execute the same search query via Java SDK I have empty rows

Code:

try (Cluster cluster = Cluster.connect(
                "host",
                "username",
                "pass"
        )) {
            QueryResult queryResult = cluster.query(s1, QueryOptions.queryOptions().readonly(true));
            SearchResult testGeopoint = cluster.searchQuery("geo-test", SearchQuery.geoPolygon(List.of(
                    Coordinate.ofLonLat(lat, long),
                    Coordinate.ofLonLat(lat, long),
                    Coordinate.ofLonLat(lat, long),
                    Coordinate.ofLonLat(lat, long),
                    Coordinate.ofLonLat(lat, long),
                    Coordinate.ofLonLat(lat, long),
                    Coordinate.ofLonLat(lat, long)
            )));
            SearchResult result = cluster.searchQuery("geo-test", SearchQuery.queryString(s));
            System.out.println(result.toString());


        } catch (Exception e) {
            e.printStackTrace();
        }

Search index:

Query as a string:

      {
             "query": {
             "field": "geo",
                     "polygon_points": [
                     "lat,long",
                     "lat,long",
                     "lat,long",
                     "lat,long",
                     "lat,long",
                     "lat,long"
    ]
         }
         }

Appreciate your help !

Hi @sprnm,

The first parameter of Coordinate.ofLonLat should be the longitude. Does swapping the argument order solve the problem?

Thanks,
David

1 Like

Thanks, David!

Missed the order of lat long, it solved the problem

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