0

how to query with subselection ? f.e. I have an attribute in my schema with:

{
      "dataType": ["geoCoordinates"],
      "description": "The geocoordinate of the company",
      "name": "coordinates"
  }

Now geoCoordinates have latitude and longitude as subselection When query with

client.query.get(class_name=class_name, properties=[coordinates]).do()

I get the following error:

'Field "coordinates" of type "ArticlecoordinatesGeoCoordinatesObj" must have a sub selection.'

How to specify the sub-selection ?

1 Answers1

0

Duda from Weaviate here!

As coordinates is a GeoCoordinates dataype, You now have to pass the subselection of fields you want to query. For instance:

coordinates = "coordinates{latitude longitude}"

So your python client query, considering you also have a "title" field would be:

client.query.get(class_name=class_name, properties=["title", "coordinates{latitude longitude}"]).do()

A nice tip is that you can always inspect the resulting graphql query using build(), like so:

client.query.get(class_name=class_name, properties=["title", "coordinates{latitude longitude}"]).build()

It will return you the exact graphql query generated, for instance:

'{Get{Article{title coordinates{latitude longitude}}}}'

Duda Nogueira
  • 317
  • 2
  • 6