Commit b56c3956 authored by Giuseppe Tropea's avatar Giuseppe Tropea
Browse files

Merge branch 'fix/34-matching-algorithm' into 'master'

DATA(26)000012_NGSI-LD_Core_Matching_Algorithm

See merge request !28
parents d4a1065f b4383a25
Loading
Loading
Loading
Loading
+56 −43
Original line number Original line Diff line number Diff line
@@ -375,6 +375,8 @@ exhausted.


## 9.4 Matching Context Source registrations
## 9.4 Matching Context Source registrations


### 9.4.1 Introduction

When querying [Context Source Registrations]{.HTML-Keyboard} as described in
When querying [Context Source Registrations]{.HTML-Keyboard} as described in
Clause+++clause-12+++12.3.3 and subscribing to [Context Source
Clause+++clause-12+++12.3.3 and subscribing to [Context Source
Registrations]{.HTML-Keyboard} as described in Clause+++clause-12+++12.4.2, the
Registrations]{.HTML-Keyboard} as described in Clause+++clause-12+++12.4.2, the
@@ -404,53 +406,64 @@ least one of:


<!-- prettier-ignore-start -->
<!-- prettier-ignore-start -->


a. selector of Entity Types
1. selector of Entity Types
b. list of Attribute names.

2. list of Attribute names.


<!-- prettier-ignore-end -->
<!-- prettier-ignore-end -->


### 9.4.2 Matching algorithm

A specification of Entity Types or Attributes matches a [Context Source 
A specification of Entity Types or Attributes matches a [Context Source 
Registration]{.HTML-Keyboard} if at least one of the _RegistrationInfo_ elements
Registration]{.HTML-Keyboard} if at least one of the _RegistrationInfo_ elements
(defined in Clause 5.2.6.6.4) in the _`information`_ element matches. An Entity
(defined in clause 5.2.6.6.5) inside the _`information`_ element matches.
specification matches a _RegistrationInfo_ if the following conditions hold:


A _RegistrationInfo_ shall match the Entity specification when the following conditions 
- If present, the selector of Entity Types, Entity identifiers and id pattern
apply:
  match at least one of the _EntityInfo_ elements of the _RegistrationInfo_ (see

  below).
1. Matching Entity Types / Entity Identifiers / idPattern
- If present, the Attribute identifiers match the combination of Properties and

  Relationships specified in the _RegistrationInfo_ (see below).
   If present, the selector of Entity Types, Entity identifiers, and _`idPattern`_ shall match

   at least one of the _`EntityInfo`_ elements contained in the _RegistrationInfo_
An Entity specification consisting of selector of Entity Types, Entity
   (see "Entity matching" details below).
identifiers and id pattern matches an _EntityInfo_ element of the

_RegistrationInfo_ if the type selector matches the entity types in the
2. Matching Attributes
_EntityInfo_ element (defined in clause 5.2.6.6.2) and one of the following

conditions holds:
   If present, the specified Attribute identifiers shall match the _`attributeNames`_ (or

   the combination of _`propertyNames`_ and _`relationshipNames`_) in the _RegistrationInfo_
- The _EntityInfo_ contains neither an _`id`_ nor an _`idPattern`_.
  (see "Attribute matching" details below).
- One of the specified Entity identifiers matches the _`id`_ in the

  _EntityInfo_.
**Entity matching**
- At least one of the specified Entity identifiers matches the _`idPattern`_ in

  the _EntityInfo_.
An Entity specification containing a selector of Entity Types, Entity identifiers, and/or 
- The specified id pattern matches the _`id`_ in the _EntityInfo_.
an _`idPattern`_ shall match an _`EntityInfo`_ element of a _RegistrationInfo_ if:
- Both a specified id pattern and an _`idPattern`_ in the _Entity Info_ are
- The Entity Type selector matches the Entity Types in the EntityInfo (see clause 5.2.6.6.2),
  present (since in the general case it is not easily feasible to determine if
and
  there can be identifiers matching both patterns).
- One of the following identifier conditions shall hold:

  - The EntityInfo contains neither an _`id`_ nor an _`idPattern`_.
Attribute names match the combination of Properties and Relationships if one of
  - A specified Entity identifier matches the _`id`_ in the _EntityInfo_.
the following conditions hold:
  - A specified Entity identifier matches the _`idPattern`_ in the _EntityInfo_.

  - The specified _`idPattern`_ matches the _`id`_ in the _EntityInfo_.
- No Attribute names have been specified (as this means all Attributes are
  - Both a specified _`idPattern`_ and an _`idPattern`_ in the _EntityInfo_ are present 
  requested).
  (because, in general, determining whether their sets of possible identifiers overlap is not
- The combination of Properties and Relationships is empty (as this means only
  feasible).
  Entities have been registered and the [Context Sources]{.HTML-Keyboard} may

  have matching Property or Relationship instances).
**Attribute matching**
- If at least one of the specified attribute names matches a Property or

  Relationship specified in the _RegistrationInfo_.
Specified Attribute names shall match the _`attributeNames`_ or the combination of 

_`propertyNames`_ and _`relationshipNames`_ defined in a _RegistrationInfo_ when any of the
If the request that triggered the matching includes a _`datasetId`_ parameter
following holds:
and the CSourceRegistration to be matched contains a _`datasetId`_ element, the
- No Attribute names are specified in the request (meaning: all attributes are requested).
CSourceRegistration should only be considered matching, if both have at least
- The _RegistrationInfo_ defines no _`attributeNames`_ (or combination of _`propertyNames`_ and
one value in common. If only one of them specifies a _`datasetId`_, it is
  _`relationshipNames`_ (meaning: only Entities are registered, and the Context Source may still
  provide matching Properties or Relationships).
- At least one specified Attribute name matches an _`attributeName`_ (or _`propertyName`_ or 
  _`relationshipName`_ listed in the _RegistrationInfo_.

If the incoming request that triggered the matching includes a _`datasetId`_ parameter
and the [Context Source Registration]{.HTML-Keyboard} to be matched contains a _`datasetId`_ 
element, the [Context Source Registration]{.HTML-Keyboard} should only be considered matching,
if both have at least one value in common. If only one of them specifies a _`datasetId`_, it is
considered a match.
considered a match.


In the case of distributed operations (see Clause+++clause-9+++9.7), where a
In the case of distributed operations (see Clause+++clause-9+++9.7), where a