Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

CONNECT data services developer documentation

Search in SDS

  • Last UpdatedOct 03, 2023
  • 9 minute read

You can search for objects using texts, phrases, and fields in Sequential Data Store (SDS). The REST APIs (or .NET client libraries methods GetStreamsAsync, GetTypesAsync, and GetStreamViewsAsync) return items that match the search criteria within a given namespace. By default, the query parameter applies to all searchable object fields.

For example, a namespace contains the following streams:

streamId Name Description
stream1 tempA Temperature from DeviceA
stream2 pressureA Pressure from DeviceA
stream3 calcA Calculation from DeviceA values

A GetStreamsAsync call with different queries returns:

Query string Returns
temperature stream1
calc* stream3
DeviceA* stream1, stream2, stream3
humidity* nothing

Requests

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query=name:pump name:pressure&orderby=name

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query=name:pump name:pressure&orderby=id asc

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query=name:pump name:pressure&orderby=name desc

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query=name:pump name:pressure&orderby=name desc&skip=10&count=20

Parameters

Parameter Required? Description
string query Optional Parameter representing the search criteria. If unspecified, returns all values. Can be used with skip, count, and orderby.
int skip Optional Parameter representing the zero-based offset of the first SdsStream to retrieve. The number of matched items to skip over before returning. If unspecified, a default value of 0 is used. Use when more items match the search criteria than can be returned in a single call.
int count Optional Parameter representing the maximum number of streams to retrieve. If unspecified, a default value of 100 is used.
string orderby Optional Parameter representing the sorted order in which streams are returned. Requires a field name (orderby=name, for example). Default order is ascending (asc). Add desc for descending order (orderby=name desc, for example). If unspecified, there is no sorting of results.

.NET client libraries methods

If there are 175 streams that match the search criteria "temperature" in a single call for example, the following call returns the first 100 matches:

_metadataService.GetStreamsAsync(query:"temperature", skip:0, count:100)

If skip is set to 100, the following call returns the remaining 75 matches while skipping over the first 100:

_metadataService.GetStreamsAsync(query:"temperature", skip:100, count:100)

Search for streams

Streams search is exposed through the REST API and the client libraries method GetStreamsAsync.

For more information on stream properties, see Stream properties.

Searchable properties

Property Searchable
Id Yes
TypeId Yes
Name Yes
Description Yes
Indexes No
InterpolationMode No
ExtrapolationMode No
PropertyOverrides No

Searchable child resources

Property Searchable
Metadata1 Yes
Tags1 Yes
ACL No
Owner No

1:You can access stream metadata and tags through Metadata API and Tags API respectively. Metadata and tags are associated with streams and can be used as search criteria. For more information, see How search works with stream metadata.

Request

Search for streams using the REST API and specifying the optional query parameter:

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query={query}&skip={skip}&count={count}

Parameters

Parameter Required? Description
string query Optional Parameter representing the search criteria. If unspecified, returns all values. Can be used with skip, count, and orderby.
int skip Optional Parameter representing the zero-based offset of the first SdsStream to retrieve. If unspecified, a default value of 0 is used. Use when more items match the search criteria than can be returned in a single call.
int count Optional Parameter representing the maximum number of streams to retrieve. If unspecified, a default value of 100 is used.

.NET client libraries method

GetStreamsAsync is used to search for and return streams.

_metadataService.GetStreamsAsync(query:"QueryString", skip:0, count:100);

The stream fields valid for search are identified in the fields table located in Stream properties. Note that stream metadata has unique syntax rules. See How search works with stream metadata.

Search for types

Type search is exposed through the REST API and the client libraries method GetTypesAsync. For more information on type properties, see SdsType fields and properties.

Searchable properties

Property Searchable
Id Yes
Name Yes
Description Yes
SdsTypeCode No
InterpolationMode No
ExtrapolationMode No
Properties Yes, with limitations1

1:Name and Id of an SdsType are included in its Properties field. Similarly, Name and Id of a nested type are included in its Properties. If there are two types with the same Properties, Name or Id, the search returns both types in the result.

Request

Search for types using the REST API and specifying the optional query parameter:

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Types?query={query}&skip={skip}&count={count}

Parameters

Parameter Required? Description
string query Optional Parameter representing the search criteria. If unspecified, returns all values. Can be used with skip, count, and orderby.
int skip Optional Parameter representing the zero-based offset of the first type to retrieve. If unspecified, a default value of 0 is used. Use when more items match the search criteria than can be returned in a single call.
int count Optional Parameter representing the maximum number of types to retrieve. If unspecified, a default value of 100 is used.

.NET client libraries method

GetTypesAsync is used to search for and return types.

_metadataService.GetTypesAsync(query:"QueryString", skip:0, count:100);

Search for stream views

Stream view search is exposed through the REST API and the client libraries method GetStreamViewsAsync. For more information on stream view properties, see Stream views.

Searchable properties

Property Searchable
Id Yes
Name Yes
Description Yes
SourceTypeId Yes
TargetTypeId Yes
Properties Yes, with limitations1

1The Properties collection contains a list of SdsStreamViewProperty objects. The query attempts to find a match on the SdsStreamViewProperty's Id, SourceTypeId, and TargetTypeId fields. The Properties collection of nested views is also searched. See the example below.

Example

You can search for ComplexView using the Id("NestedView"), SourceTypeId, and TargetTypeId of NestedView, but not its Description ("An example of a nested view").

{
  "Id": "ComplexView",
  "Name": "ComplexView",
  "SourceTypeId": "ComplexSourceType",
  "TargetTypeId": "ComplexTargetType",
  "Description": null,
  "Properties": [
    {
      "SourceId": "Value",
      "TargetId": "Value",
      "SdsStreamView": {
        "Id": "NestedView",
        "SourceTypeId": "NestedType",
        "TargetTypeId": "NestedType",
        "Description": "An example of a nested view",
        "Properties": [
          {
            "SourceId": "Value",
            "TargetId": "Value"
          }
        ]
      }
    }
  ]
}

Request

Search for stream views using the REST API and specifying the optional query parameter:

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/StreamViews?query={query}&skip={skip}&count={count}

Parameters

Parameter Required? Description
string query Optional Parameter representing the search criteria. If unspecified, returns all values. Can be used with skip, count, and orderby.
int skip Optional Parameter representing the zero-based offset of the first stream view to retrieve. If unspecified, a default value of 0 is used. Use when more items match the search criteria than can be returned in a single call.
int count Optional Parameter representing the maximum number of stream views to retrieve. If unspecified, a default value of 100 is used.

.NET client libraries method

GetStreamViewsAsync is used to search for and return stream views.

_metadataService.GetStreamViewsAsync(query:"QueryString", skip:0, count:100);

Tokenization

Tokenization is the process of breaking a string sequence into pieces called tokens using specific characters to delimit tokens. User-specified queries are tokenized into search terms. How the query string is tokenized can affect search results.

Delimit the terms with either:

  1. A space.

  2. One or more punctuation characters (*, !, ?, ., for example) and a space. Any query string followed without a space or by other punctuation characters does not trigger tokenization and is treated as part of the term.

If your query has a wildcard (*) operator after a punctuation character, neither the punctuation nor the wildcard operator is tokenized. To specifically search for a term that has trailing punctuation, enclose the query in quotation marks to ensure that the punctuation is part of the query. See examples below:

Term Tokenized Term Description
Device.1 Device.1 The token includes .1 because there is no space between it and Device.
Device!!1 Device!!1 The token includes !!1 because there is no space between it and Device.
Device.  Device . and the following space demarcates Device as the token term.
Device!!  Device !! and the following space demarcates Device as the token term.
Device!* Device The token does not include !* because neither is tokenized if a wildcard operator follows a punctuation character.
"Device!"* Device! Device! is the token because the string is enclosed in double quotes.

Search operators

You can use search operators in the query string to get more refined search results. Use operators AND,OR, and NOT in all caps.

Operator Description
AND AND operator. cat AND dog searches for both "cat" and "dog".
OR OR operator. cat OR dog searches for either "cat" or "dog", or both.
NOT NOT operator. cat NOT dog searches for "cat" or those without "dog".
* Wildcard operator. Matches 0 or more characters. log* searches for those starting with "log" ("log", "logs" or "logger" for example.); ignores case.
: Field-scoped query. Specifies a field to search. id:stream* searches for streams whose id field starts with "stream", but will not search other fields like name or description. See Field-scoping operator below.
" " Quote operator. Scopes the search to an exact sequence of characters. While dog food (without quotes) searches for instances with "dog" or "food" anywhere in any order, "dog food" (with quotes) only matches instances that contain the whole string together and in that order.
( ) Precedence operator. motel AND (wifi OR luxury) searches for either "wifi" or "luxury", or "wifi" and "luxury" at the intersection of "motel".

Examples

Query string Matches field value Does not match field value
mud AND log log mud
mud log
mud
log
mud OR log log mud
mud
log
mutt
look
mud AND (NOT log) mud mud log
mud AND (log OR pump*) mud log
mud pumps
mud bath
name:stream* AND (description:pressure OR description:pump) The name starts with "stream" and the description has either "pressure", "pump", or both. string

Field-scoping (:) operator

You can qualify the search to a specific field using the : operator.

fieldname:fieldvalue

Request

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query=name:pump name:pressure

.NET client libraries method

GetStreamsAsync(query:"name:pump name:pressure");

Wildcard (*) operator

You can use the wildcard operator (*) to complement an incomplete string. It can only be used once per token, unless there is one at the beginning and another at the end (*Tank* but not *Ta*nk, Ta*nk*, or *Ta*nk*, for example).

Query string Matches field value Does not match field value
log* log
logger
analog
*log analog
alog
logg
*log* analog
alogger
lop
l*g log
logg
lake swimming (* does not span across two tokens)
Supported Not Supported
*
*log
l*g
log*
*log*
"my log"*
*l*g*
*l*g
l*g*
"my"*"log"

Request

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query=log*

.NET client libraries method

GetStreamsAsync(query:"log*");

Double quotes ("") operator

Tokenized search terms are delimited by whitespace and punctuation. To include these delimiters in a search, enclose them in double quotes.

When using double quotes, the matching string must include the whole value of the field on the object being searched. Partial strings are not matched unless wildcards are used. For example, if you are searching for a stream with the description Pump three on unit five, a query "unit five" will not match the description, but *"unit five" will.

Note that while you can use a wildcard (*) either inside or outside of quotes, it is treated as a string literal inside quotes. For example, you can search for "dog food"* to find a string that starts with "dog food", but if you search for "dog food*", it only matches the value of "dog food*".

Query string Matches field value Does not match field value
"pump pressure" pump pressure pressure
pressure pump
pump pressure gauge
"pump pressure"* pump pressure
pump pressure gauge
pressure
pressure pump
the pump pressure gauge
*"pump pressure" pump pressure
the pump pressure
pressure
pressure pump
the pump pressure gauge
*"pump pressure"* pump pressure
pump pressure gauge
the pump pressure gauge
pressure
pressure pump
"pump*pressure" pump*pressure pump pressure
the pump pressure gauge

Request

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query="pump pressure"

.NET client libraries method

GetStreamsAsync(query:"\\"pump pressure\\"");

How search works with stream metadata

Stream metadata behaves differently with search syntax rules described in the previous sections.

A namespace with streams with respective metadata key-value pairs

streamId Metadata
stream1 { manufacturer, company }
{ serial, abc }
stream2 { serial, a1 }
stream3 { status, active }
{ second key, second value }

Field-scoping (:) Operator

Stream metadata key is only searchable in association with its value. This pairing is defined using the field-scoping (:) operator.

myStreamMetadataKey:myStreamMetadataValue

Metadata key is not searched if the operator (:) is missing in the query string. The search is then limited to metadata values along with other searchable fields in the stream.

Query string Returns Description
manufacturer:company stream1 Searches and returns stream1.
company stream1 Searches only the metadata values due to lack of : operator and returns stream1.
a* stream1, stream2, stream3 Searches the metadata values and returns all three streams.

Request

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query=manufacturer:company

.NET client libraries method

GetStreamsAsync(query:"manufacturer:company");

Wildcard (*) Operator

Wildcard (*) character can be used in both metadata keys and values with one caveat: a wildcard (*) used in the field (left of field-scoped operator (:)) only searches within SdsStream metadata.

Query string Returns Description
manufa*turer:compan* stream1 Searches and returns stream1.
ser*al:a* stream1, stream2 Searches and returns stream1 and stream2.
s*:a* stream1, stream2, stream3 Searches and returns all three streams.
Id:stream* stream1, stream2, stream3 Searches all fields and returns three streams.
Id*:stream* nothing Wildcard in the field limits the search to metadata. Returns nothing because there is no metadata by that name that meets the criteria.

Request

GET api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams?query=manufa*turer:compan*

.NET client libraries method

GetStreamsAsync(query:"manufa*turer:compan*");

Special characters in search queries

Add the backslash escape character ( \ ) before any special characters in search queries. The following special characters require an escape character:

" | / \* \ ( ) :

The following are examples of using the escape character in query strings.

Example Field Value Query String
Austin\Dallas\Fort Worth Austin\\Dallas\\Fort Worth
1:100 1\:100
TitleResults for “How to create a CRG?”Also Available in