in source/packages/services/assetlibrary/src/search/search.lite.dao.ts [38:104]
private buildQueryString(request: SearchRequestModel): string {
logger.debug(`search.lite.dao buildQueryString: in: request: ${JSON.stringify(request)}`);
const filters: string[] = [];
// if a group is provided, that becomes the starting point
if (request.ancestorPath !== undefined) {
const field = this.isDevice(request.types) ? 'thingGroupNames' : 'parentGroupNames';
filters.push(`${field}:${request.ancestorPath}`);
}
// filtering by custom types
if (this.isDevice(request.types)) {
const customType = request.types.filter(
(t) => t !== TypeCategory.Device && t !== TypeCategory.Group
)[0];
if (customType !== undefined && customType !== null) {
filters.push(`thingTypeName:${customType}`);
}
}
if (request.eq !== undefined) {
request.eq.forEach((filter) => {
filters.push(`${this.getFilterKey(filter['field'])}:${filter['value']}`);
});
}
if (request.neq !== undefined) {
request.neq.forEach((filter) => {
filters.push(`NOT ${this.getFilterKey(filter['field'])}:${filter['value']}`);
});
}
if (request.lt !== undefined) {
request.lt.forEach((filter) => {
filters.push(`${this.getFilterKey(filter['field'])} < ${filter['value']}`);
});
}
if (request.lte !== undefined) {
request.lte.forEach((filter) => {
filters.push(`${this.getFilterKey(filter['field'])}<=${filter['value']}`);
});
}
if (request.gt !== undefined) {
request.gt.forEach((filter) => {
filters.push(`${this.getFilterKey(filter['field'])}>${filter['value']}`);
});
}
if (request.gte !== undefined) {
request.gte.forEach((filter) => {
filters.push(`${this.getFilterKey(filter['field'])}>=${filter['value']}`);
});
}
if (request.startsWith !== undefined) {
request.startsWith.forEach((filter) => {
filters.push(`${this.getFilterKey(filter['field'])}:${filter['value']}*`);
});
}
if (request.endsWith !== undefined) {
throw new NotSupportedError();
}
if (request.contains !== undefined) {
throw new NotSupportedError();
}
const filtersAsString = filters.join(' ');
logger.debug(`search.lite.dao buildQueryString: filters: ${filtersAsString}`);
return filtersAsString;
}