Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter by attribute in nosignal rules #735

Open
manucarrace opened this issue Jul 14, 2023 · 8 comments
Open

Filter by attribute in nosignal rules #735

manucarrace opened this issue Jul 14, 2023 · 8 comments

Comments

@manucarrace
Copy link
Collaborator

manucarrace commented Jul 14, 2023

Current implementation of nosignal rules only allows to filter by Id and type. It would be nice to have an aditional filter by attribute, both at context broker level and mongo level.

More details about this issue to be provided.

@manucarrace manucarrace changed the title Filter by attribute in no signal action Filter by attribute in nosignal rules Jul 14, 2023
@fgalan
Copy link
Member

fgalan commented Aug 7, 2023

I understand the issue refers to "attribute existance".

NGSIv2 API (case when PERSEO_CHECK_NON_SIGNAL_BY_API is in use):

From: https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#simple-query-language

The unary statements are used to check for the existence of the target property. E.g. temperature matches entities that have an attribute called 'temperature' (no matter its value),

For instance, this is the filter to match entities that have an attribute named temperature:

?q=temperature

MongoDB query (case when PERSEO_CHECK_NON_SIGNAL_BY_API is not in use):

From https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/admin/database_model.md#entities-collection

attrNames: an array of strings. Its elements are the names of the attributes of the entity (without IDs). In this case, the "." to "=" replacement is not done.

So for instance a query like the following one matches entities that have an attribute named temperature

db.entities.find({attrName: "temperature"})

@manucarrace
Copy link
Collaborator Author

Mybe not only existance but attribute value

@fgalan
Copy link
Member

fgalan commented Aug 22, 2023

Mybe not only existance but attribute value

Which value should be checked? Could you formulate the attribute value condition (in English) so I can "translate" to queries?

@manucarrace
Copy link
Collaborator Author

I would like to check the absence of data only for entities of type Streetlight with temperature > 100 or flag == true

@fgalan
Copy link
Member

fgalan commented Aug 29, 2023

I think I misunderstood the original description of this issue...

Considering the new statement

I would like to check the absence of data only for entities of type Streetlight with temperature > 100 or flag == true

Let's consider just only one condition:

I would like to check the absence of data only for entities of type Streetlight with temperature > 100

would be

  • CB API: ?q=temperature>100
  • MongoDB query: db.entities.find({"attrs.temperature.value": {$gt: 100}})

I would like to check the absence of data only for entities of type Streetlight with flag == true

would be

  • CB API: ?q=flag:true
  • MongoDB query: db.entities.find({"attrs.flag.value": true})

The problem is with the or condition. CB API doesn't support or. But if we change to and, this way:

I would like to check the absence of data only for entities of type Streetlight with temperature > 100 and flag == true

would be

  • CB API: ?q=temperature>100;flag:true
  • MongoDB query: db.entities.find({"attrs.temperature.value": {$gt: 100}, "attrs.flag.value": true})

@manucarrace
Copy link
Collaborator Author

Possible use case in order to ease the understanding of the issue. In a given subservice I could have some entities cosidered as "static" (they don't receive periodic data). These entities, could be of the same type than others consided as "dinamic" (they receive data on a period basis).

For instance, I may have several streetlights sending data to the platform but some other just for inventary purposes. In this case, I would like to check the absence of data only for those entities considered as dinamic. I can mark these entities with a flag attribute and then state this attribute in the rule in order to filter the entities.

@fgalan
Copy link
Member

fgalan commented Sep 14, 2023

Possible use case in order to ease the understanding of the issue. In a given subservice I could have some entities cosidered as "static" (they don't receive periodic data). These entities, could be of the same type than others consided as "dinamic" (they receive data on a period basis).

For instance, I may have several streetlights sending data to the platform but some other just for inventary purposes. In this case, I would like to check the absence of data only for those entities considered as dinamic. I can mark these entities with a flag attribute and then state this attribute in the rule in order to filter the entities.

So I understand we don't need combine several filters at the same time (only one, i.e. flag equality for true). Thus, in my opinion this fits perfectly with the above proposal.

@AlvaroVega
Copy link
Member

Related PR about nosignal filters: #726

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants