Skip to main contentIBM Maximo REST API Guide

Filtering

Where Filters - oslc.where

The most common way to filter a resource set is to use the oslc.where query parameter. This parameter internally maps to the Maximo QBE framework. You can filter data that is based on all persistent attributes, at the main MBO (for the OS) or any related MBO. In the example, the where clause filters assets that are based on locations and the asset status.

GET /oslc/os/mxapiasset?oslc.where=status="OPERATING" and location.status="OPERATING"&lean=1

The locations MBO is not part of the MXAPIASSET object structure. The format for the dot notation (location.status) is <rel1>[.rel2]*.attr1. As you can make out, the dot notation can be nested. The leaf element is always an attribute in the target Mbo.

The following table describes the different operators that you can use for filtering data:

OperatorDescriptionUsage
=equalsstatus="APPR"
>=Greater than equalspriority>=1
>Greater thanstartdate>"iso date"
<Less thanstartdate<"iso date"
<=Less than equalslinecost<=200.5
!=Not equalspriority!=2
inIn clauselocation in ["A","B","C"], priority in [1,2,3]

This query language is data type sensitive and the double quotes "" is used for character based attributes and for dates (ISO Format). Numeric values are represented in their corresponding ISO formats (that is non localized format). Boolean values are always represented either as 1/0 or true/false (no quotes).

oslc.where=status in ["OPERATING","ACTIVE"] and priority=3 and statusdate>"ISO date string" and linear=false

You can use the in clause with numeric values too.

oslc.where=priority in [1,2,3]

For the LIKE clause, you can use the following variations:

oslc.where=status="%APPR%"

If you want to use starts with:

oslc.where=status="APPR%"

If you want to use ends with:

oslc.where=status="%APPR"

To use null value queries, you can use the star (*) notation. For example, a not null check is completed by using the following format where - status is not null.

oslc.where=status="*"

If you want to use the is null check:

oslc.where=status!="*"

If you want to use a not in clause, you can use the following format:

location!= "[BR300,BR400]"

Note that this not in clause currently only works for ALN attributes.

Range Filters

Range filters are used to support range based queries. For example, if you want to only get assets within a certain date range and priority range, you can use this feature.

oslc.where=priority>1 and priority<=3 and installdate>="1999-02-06T00:00:00-05:00" and installdate<"2009-02-06T00:00:00-05:00"

You can also filter with date ranges by using timeline queries.

SynonymDomain Internal Filters

You can also filter by using the internal values for synonymdomains. The following example shows how you can filter the work order objects that are based on the internal values for the status attribute (bound to the WOSTATUS synonymdomain).

GET <collection uri>?oslc.where=...&domaininternalwhere=status!=APPR,INPRG

This will filter the work order collection using the not in clause for the set of external values that correspond to the internal values of APPR and INPRG. We can use a in comparison by changing the expression like below:

GET <collection uri>?oslc.where=...&domaininternalwhere=status=APPR,INPRG

There are a few things to note:

  • The domaininternalwhere query parameter is independent of the oslc.where and is ANDed to the oslc.where clause (if oslc.where is present in the request).
  • The format is <attr name>[=/!=]internal_val1,internal_val2,...
  • This feature always generates an SQL with in or a not in operator depending on whether the = or != operator was used.
  • The list of internal values need to be comma delimited.
  • There can be one or many internal values and null is not allowed in this value set.

MaxTableDomain Based Filters

You can also filter using the maxtabledomain list WHERE clause. The maxtabledomain is more useful for backward compatibility reasons with the older rest API and also in case a client wants to use an existing list WHERE clause that was created by using the table-domain. The API syntax is shown:

GET <collection uri>?_fd=<maxtabledomain name>&_fdsite=<siteid>&_fdorg=<orgid>

This API picks up the domain’s listwhere and applies that to the collection. The site and organization are optional and needed if the maxtabledomain is site/org scoped.

Timeline Filters

The timeline filters allow a simpler way to filter collections with time range based queries. The following example shows how you can list all work orders reported in the past three months:

GET /oslc/os/mxapiwodetail?tlrange=-3M&tlattribute=reportdate

This query finds all the work orders with a reportdate between today and the previous three months. The query is by default indexed around the current date. Another variation of this query is to range on a future date by switching the sign on the tlrange to say +3M instead of -3M. For reportdate a future date range may not be good use case, but it would for date attributes like scheduled date that can be in the future. You might also use the current date as an index and filter around that date using the +- notation as shown in the following example:

&tlrange=+-3Y

This query filters records from three years in the past and three years in the future that is indexed on the current date. If you do not want to index on the current date, you can specify the date that you want to use for the index. The following example shows how you can specify the date:

&tlattribute=reportdate=<some iso date>

Maximo objects, such as assets, locations, items, and work orders can be associated with classifications to provides a way to associate classification metadata (aka classification attributes) to the objects. These objects (assets,locations etc) are searched for based on those attribute values. This search capability is known as the attribute search feature. The following example shows an attributesearch that is applied to the asset MBO by using the MXAPIASSET object structure.

GET oslc/os/mxapiasset?attributesearch=[SPEED:>=50]

All assets that have a class spec attribute called SPEED with a value >=50 are searched for. If the value :>=50 is not defined, then assets that have SPEED as a specific attribute is returned.

GET oslc/os/mxapiasset?attributesearch=[SPEED]

It would have only fetched assets that have SPEED as a spec attribute. To combine multiple attributes in the search, you can use the following example:

GET oslc/os/mxapiasset?attributesearch=[SPEED:>=50;AREA;ELEV:=300]

This query searches for assets that have a class spec attribute SPEED with a value that is greater than 50, an attribute named AREA, and attribute name ELEV with a value of 300, all ANDed together.

This feature is in addition to the oslc.where/savedquery query parameter. So you can use this feature along with the other filtering capabilities that are supported in this API framework.