Composer의 ThingWorx 모델 정의 > 모델링 > 사물 > 사물 서비스 > 질의 서비스의 질의 매개 변수
질의 서비스의 질의 매개 변수
여러 ThingWorx 서비스에서 선택 질의 매개 변수를 허용합니다. 질의 매개 변수는 요청되는 질의 유형에 따라 다르게 구성된 값 객체입니다.
가능한 유형은 다음과 같습니다.
Matches, NotMatches TaggedWith,
NotTaggedWith
GT, LT, GE, LE, NE, EQ, LIKE, NOTLIKE, IN, NOTIN
Between, NotBetween MissingValue,
NotMissingValue Near, NotNear
질의는 AND/OR일 수 있으며 정렬을 포함할 수 있습니다.
질의 매개 변수는 그 중에서도 질의로 시작하는 모든 서비스에서 사용됩니다.
모든 사물
QueryThingStreamEntries
모든 스트림
QueryStreamData
QueryStreamEntries
QueryStreamEntriesWithData
모든 데이터 테이블
QueryDataTableEntries
InfoTableFunctions 리소스
Query
모든 사물 템플릿
QueryImplementingThings
QueryImplementingThingsWithData
모든 사물 형태
QueryImplementingThings
QueryImplementingThingsWithData
감사 하위 시스템
구성
질의 매개 변수에는 필터와 정렬기라는 두 가지 구성 가능한 옵션이 있습니다. 질의 매개 변수를 정의한 후 질의 서비스로 전달할 수 있습니다. 다음은 질의 매개 변수에 대한 필터 및 정렬 옵션의 예입니다. 스크립트 구성자의 스크립팅 도구 및 조각을 시작점으로 사용하고 적절한 경우 질의 매개 변수 객체를 수동으로 만드는 것이 좋습니다.
단일 필터 옵션
Matches 또는 NotMatches 필터
var query =
{
"filters": {
"type": "Matches|NotMatches",
"fieldName": "Source",
"expression": "(Kettle)|(Filler)"
}
};
TAGGED 또는 NOTTAGGED 필터
var query = {
"fieldName": "tags",
"type": "NOTTAGGED",
"tags": [
{
"vocabulary": "Applications",
"vocabularyTerm": "Testing"
},
{
"vocabulary": "Plants",
"vocabularyTerm": "Sedona"
}
]
};
단일 비교자
* 
LIKE/NOTLIKE를 사용할 때는 와일드카드(단일 문자 와일드카드에 대해 %, * 또는 ?)를 추가해야 합니다. 예를 들어, ThingWorx를 찾으려면 LIKE Th%를 사용합니다.
var query = {
"filters":{
"type": "GT, LT, GE, LE, NE, EQ, LIKE, NOTLIKE",
"fieldName": "<field_name>",
"value": "Th\\+*"
}
};
In 또는 NotIn 필터
var jsonArray = [12,14];
var query = {
"filters": {
"type": "IN, NOTIN",
"fieldName": "Duration",
"values": jsonArray
}
};
Between 또는 NotBetween 필터
var query =
{
"filters": {
"type": "Between, NotBetween",
"fieldName": "Duration",
"from": "2",
"to": "12"
}
};
MissingValue 또는 NotMissingValue 필터
var query =
{
"filters": {
"type": "MissingValue, NotMissingValue",
"fieldName": "OrderQuantity"
}
};
Near 또는 NotNear 필터
var query =
{
"filters": {
"type": "Near, NotNear",
"fieldName": "fieldName",
"distance": "50",
"units": "M(iles), K(ilometers), N(autical miles)",
"location": {
"latitude": "40.12",
"longitude": "51.24",
"elevation": "300",
"units": "WGS84"
}
}
};
복합 필터 옵션
And 또는 Or 필터 유형을 사용하여 여러 필터를 결합할 수 있습니다. 아래의 예는 지속 시간이 12초를 넘고 태그 필드에 정전 관련 문제라는 태그가 지정된 행을 필터링합니다.
var query =
{
"filters": {
"type": "And",
"filters": [
{
"type": "GT",
"fieldName": "Duration",
"value": "12"
},
{
"type": "TaggedWith",
"fieldName": "tags",
"tags": "MaintenanceIssues:PowerOutage"
}
]
}
};
서로 다른 And/Or 유형의 중첩 필터
서로 다른 And/Or 유형의 필터를 중첩하려면 JSON 객체의 각 수준에 대한 유형 및 필터 키워드가 있어야 합니다. 질의에 대한 다음 JSON 구문으로 원하는 결과를 얻을 수 있습니다(아래 예에서 empty로 바뀌는 빈 문자열 제외).
var query3 = {
"filters": {
"type": "AND",
"filters": [
{
"type": "OR",
"filters": [
{ "fieldName": "Status", "type": "LIKE", "value": "*-none-*" }
,
{ "fieldName": "Status", "type": "LIKE", "value": "empty" }
]
},
{ "fieldName": "IsDeleted", "type": "EQ", "value": false }
]
}
};
정렬 옵션
sorters 옵션은 객체 배열입니다. sorters 배열 fieldName, isAscending, isCaseSensitive에는 각각의 정렬 객체에 대해 세 가지 매개 변수가 있습니다. 필드 이름만 필요합니다. isAscending 및 isCaseSensitive의 기본값은 true입니다.
단일 정렬 옵션
var query =
{
"sorts": [
{
"fieldName": "Material"
}
]
}
복합 정렬 옵션
var query =
{
"sorts": [
{
"fieldName": "Material"
},
{
"fieldName": "OrderDate",
"isAscending": false
}
]
}
정렬 및 필터
다음 예와 같이 동일한 질의 서비스에 정렬과 필터를 적용할 수 있습니다.
var query =
{
"sorts": [
{
"fieldName": "LotID",
"isAscending": false,
"isCaseSensitive": false
},
{
"fieldName": "Plant"
}
],
"filters": {
"type": "And",
"filters": [
{
"type": "GT",
"fieldName": "Duration",
"value": "12"
},
{
"type": "TaggedWith",
"fieldName": "tags",
"tags": "MaintenanceIssues:PowerOutage"
}
]
}
};
가능한 유형
가능한 유형은 다음과 같습니다.
EQ = 같음
NE = 같지 않음
GT = 보다 큼
GE = 보다 크거나 같음
LT = 보다 작음
LE = 보다 작거나 같음
LIKE = 유사
BETWEEN
NOTBETWEEN
도움이 되셨나요?