Skip to content

Search items with semantic tags

Now that it's possible to add semantic tags on sequences (aka collection) / pictures (aka item) / part of pictures (aka annotation), we need to add API to search pictures by tags.

I think we can first implement a simple search based on the key/value equality of those tags ? And I think that if a search for a picture with a tag {"key": "traffic_sign", "value": "stop"}, we should check the pictures's semantic tags, its annotations, and its collection.

API

How should be define the API?

The obvious choice would be to implement this in the existing /search endpoint.

Parameters

CQL2

Can the CQL2 already implemented handle this?

hum the IN parameter might do the job but this won't evolve easily

/search?filter={"key": "traffic_sign", "value": "stop"} IN semantics ?

or

/search?filter=traffic_sign=stop IN semantics

But since we won't only search in .properties.semantics, I don't think it really is stacy

Custom parameter

/search?semantic=traffic_sign=stop

and we could make it later more advanced to handle something like /search?semantic=(traffic_sign=stop) or (wikidata=* AND -osm:amenity) ? Last part is either a wikidata key or no osm:amenity key (could be ! instead of -, but - is often used in stac.

Free text search

Or we could use the free text search extension that define a q parameter to do free text search agains the .properties of an item, but it would be twisting the extension since:

  • we won't search on all .properties field
  • and we could search on fields not in this response (the collection tags)
  • we would have to user a grammar like key=value which is not the real purpose of this extension

twisted filter extension

To use the already implemented CQL2 filters we have, we could also add a documented virtual property (semantic) that could be filtered using CQL2. but it don't feel natural, will surely not interface with real tools implementing the filter extension, and I don't really see how we could have use cases like "items that do not have this tag" or "items that have this key and a regexp on the value" in the futur.

OverPass like API

We could also take inspiration of the overpass api for tags ( I always felt it was quite complex 😬 but this subset is quite simple) ?

Other options ?

Anyone has better options? any standard we could use here?

Open questions

  • Should we be able to differentiate between semantic on the pictures and collections? like I want the picture that are part of a collection with this tag (but I don't want it if it has the tag directly attached to it). I don't really see a use case at the moment, but I prefer to ask if anyone see this as important.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information