Compound a column query with GeoDistanceQuery

Hi

I have a large number (millions) of documents with geolocations in

I’m able to query based on location now, but I want to also now add in an additional filter to the search to reduce the number of documents based on a column called type, and one called deleted.

I know I can filter these in code afterwards, but I’d rather return just 10s of documents from the server, rather than 1000s

I’m using the C# SDK , just unable to figure out how to add additional column query to my GeoDistanceQuery.

Any help would be greatly appreciated. Thank you

@wchandler,

You may use the compound queries like conjuncts wherein one of the child clauses will be your geo query and can have as many additional search clauses as you wish.

        {"location": {"lat": 38.8257,"lon": -122.8182},"distance": "1000mi","field": "geo"},
        {"match": "typeText","field": "type"}, 
        {"match": "typeText","field": "deleted"}
      ]}, 

ref- https://docs.couchbase.com/server/current/fts/fts-query-types.html#compound-queries

For any SDK related queries, its better post in respective forums for faster responses.

Cheers!

Thanks @sreeks I’ll give this a try and hit up the SDK forum if I get stuck

I managed to get this working using the following in the C# if anyone stumbles across looking for it:

      var locationQuery = new GeoDistanceQuery()
                        .Latitude(latitudeDouble)
                        .Longitude(longitudeDouble)
                        .Distance(distanceString);     

      var typeMatch  = new MatchQuery(typeString).Field("type");

      var deleteMatch = new MatchQuery(deletedString).Field("deleted");

       var query = new ConjunctionQuery(locationQuery , typeMatch, deleteMatch );

Then passing the query into the search.

1 Like