-
Notifications
You must be signed in to change notification settings - Fork 6
Simple Lookup Service Query Bindings
In order to quickly expose a domain class in a way that follows some of the idiomatic conventions of the FOLIO project, resource based controllers which extend com.k_int.web.toolkit.rest.RestfulController or TenantAwareRestfulController in the same package, will automatically receive an index method which supports the out of the box behavior of a standard FOLIO 3-column layout search pane.
The parameters are
| Parameter | description |
|---|---|
| offset (optional) | Search result offset |
| perPage (optional) | how many items to return per paginated page |
| page (optional) | if supplied explicit page number, if not calculated from offset and perPage |
| filters (optional) | Repeatable Additional filters applied by the query builder |
| term (optional) | The primary search string - corresponding to the text input control in the search pane. Searches can be executed using filters only |
| match (optional) | what field to use for the primary search string |
| sort (optional) | what field to sort on and direction |
| stats (optional) | Set to true to return hit counts and additional statistics |
"filters" syntax - the filters field provides a limited query language to build arbitrary expressions. N.B. this is provided as a convenience and is not intended to replace a full query implementation. Devs should also be cognizant of the tradeoffs of using fielded search APIs vs general query languages.
Query is implemented in com.k_int.web.toolkit.SimpleLookupService. Filters can be repeated, multiple filters are ANDed together and each filter is structured as
filters ::= <clause> [ <booleanOp> <query> ]
clause ::= <term> <op> <value>
booleanOp ::= && | ||
op ::= = | == | =!= | != | < | > | <= | >= !~ | =~ | =i=
term :: domain-model-property[.term]
The web toolkit supports a few basic operators for filters.
| operator | description | example |
|---|---|---|
| == | Exactly equal |
?filters=agreementName==Test will match Agreements named "Test" but not "test" or "Wibble" |
| = | Alias for ==
|
|
| != | Not equal |
?filters=agreementName!=Test will match Agreements "Test 2" and "Wibble" |
| <> | Alias for !=
|
|
| =i= | Case insensitively equal |
?filters=agreementName==Test will match Agreements named "Test" and "test" but not "Test 2" |
| =~ | Contains |
?filters=agreementName=~Test will match Agreements "Test" and "Test 2" |
| !~ | Does not contain |
?filters=agreementName!~Test will match Agreement "Wibble" |
| > | Greater than |
?filters=startDate%3E2020-02-02 will match agreements where startDate is after February 2nd 2020 |
| < | Less than |
?filters=startDate%3C2020-02-02 will match agreements where startDate is before February 2nd 2020 |
| >= | Greater or equal |
?filters=startDate%3E%3D2020-02-02 will match agreements where startDate is on or after February 2nd 2020 |
| <= | Less or equal |
?filters=startDate%3C%3D2020-02-02 will match agreements where startDate is on or before February 2nd 2020 |
| isNull | Is null match |
?filters=description%20isNull will match agreements where description is null |
| isNotNull | Is not null match |
?filters=description%20isNotNull will match agreements where description is not null |
| isSet | Is set match |
?filters=description%20isSet will match agreements where description is set |
| isNotSet | Is not set match |
?filters=description%20isNotSet will match agreements where description is not set |
| isEmpty | Is empty match |
?filters=alternateNames%20isEmpty will match agreements with no alternate names |
| isNotEmpty | Is not empty match |
?filters=alternateNames%20isNotEmpty will match agreements with alternate names |
| pattern | description | example |
|---|---|---|
| x<{var}<y | Between exclusively |
?filters=16%3Cage%3C21 will match where age is greater than 16 but less than 21 (for integers this would be 17-20) |
| x<={var}<=y | Between inclusively |
?filters=16%3C%3Dage%3C%3D21 will match where age is greater or equal to 16 and less or equal to 21 (for integers this would be 16-21) |
Note: You can mix the above operators to filter values with a mixture of inclusiveness.
i.e. 2020-02-01<=createdDate<2020-03-01 would get you things created in February 2020
| description | filter string | Notes |
|---|---|---|
| Exact match on title | filters=title%3d%3d"Quoted String" | Note = No use of term of match - just use filters for an exact match |
| Exact match on author of title | filters=title.author.name%3d%3d"Some title" | |
| Wildcard match | filters=title%3d%3d"%QuotedString%" | |
| Text match on title in search input box | term=wibble&match=title | |
| Match on ID | filters=id%3d%3d1234 | |
| Title = brain and author = beer (v1) | filters=title%3dbrain&filters=title.author.name%3dbeer | multiple filter clauses, use . operator to navigate access path from root object to field in related domain class |
| Title = brain and author = beer (v2) | filters=title%3dbrain && title.author.name%3d%3dbeer | Use && as a logical connector - direct access to match point. |
| Title = brain and author = beer (v3) | match=title&term=brain&filters=title.author.name%3d%3dbeer | This is what a standard FOLIO UI would send when filling out the input text field and setting the field combo to title then adding an author filter |