Receive answers from the OrganiCity team and other members of the community.

Search assets by metadata

0 votes
Hi everyone,

I am trying to use the Asset Discovery Service in order to search for assets with specific metadata.
I did checkout the:
- general documentation (https://docs.organicity.eu/AssetDiscoveryService/)
- the APIs documentation (https://docs.organicity.eu/api/AssetDiscovery.html#operation--assets-metadata-search-get)
- and I have also found an example on Codepen (https://codepen.io/pral2a/pen/ALxAOp)
but I have not been able to find any examples on how metadata queries should be actually created.

Could you please help me out?

In particular, I would like to be able to filter assets by type, location (lat, lon), firstEventTime and lastEventTime.

Ps. I have noticed that in the queries that I done till now the values of  firstEventTime and lastEventTime are all set to "1970-01-01T00:00:00.000Z". There may be some problems in timestamp handling.

Thanks for the support.

Carlo
asked Nov 27 in Assets by carlo.caprini (120 points)
edited Nov 27 by carlo.caprini

1 Answer

0 votes
Hi Carlo,

The metadata search traverse all the OC assets levels looking for properties and keys that inclusively match your search words.

i.e. Search for Assets containing Bikes and London

https://discovery.organicity.eu/v0/assets/metadata/search?query=bikes+london

Let us know if you need to search for something else in a different way

We hope this helps you

Guillem
answered Nov 28 by pral2a (140 points)
Hi Guillem,

thanks for the response, it helps me for sure!
The search I have in mind should also filter assets in time: is there a way of searching not only by match but also by range?

Here is a real example for my use case: I would like to search for all events taking place during the next weekend. Once identified the min and max timestamps representing my target period (the weekend) how can I create a query that filters all those events whose property firstTimeEvent is included in the period?

I am thinking about a query like this: min_timestamp < firstTimeEvent < max_timestamp .

Thanks for the support.
Carlo
Any feedback about the filter in time?

Thanks

We found the lastUpdate parameter is not working fine on the current version of the Discovery API and we are working to fix this. We should have this up and running before the end of the week.

This will allow you to use the assets query properties:

https://docs.organicity.eu/api/AssetDiscovery.html#operation--assets-get

As an example for all the assets you will do:


https://discovery.organicity.eu/v0/assets?type=event&lastUpdate=2017-07-04T12:00:47Z


 Or for an specific site:

https://discovery.organicity.eu/v0/assets/sites/santander?type=event&lastUpdate=2017-07-04T12:00:47Z

The lastUpdate attribute will return you assets updated at this time or later. However for the moment the type query works.

We'll keep you updated!

From what I can see, the firstEventTime and lastEventTime have the same issue you mentioned about the lastUpdate field.

The firstEventTime and lastEventTime are actually the fields that I would need to use for filtering assets. Please let me know:
- when the issue with the date is fixed
- how I can filter assets in the request https://docs.organicity.eu/api/AssetDiscovery.html#operation--assets-get by firstEventTime and lastEventTime

Thanks, Carlo

...