Depending on the Tipo chosen in the menu, TipoTapp automatically manages fetching and managing data in the browser.
In order to fetch data from the server with certain conditions, those conditions can be supplied by providing query in accordance with the syntax provided below under Query DSL Syntax
However, if your query is required to be dynamic, then the query can use variables as described in this article Dynamic Expressions using $tipo...
Query DSL Syntax
TipoTapp provides a Query DSL that is used when setting filters. When setting up quick filters for a Tipo or establishing relationship filters to fetch related data, queries used must follow this syntax.
The following are its specifications:
Field Names
the default_field is searched for the search terms, but it is possible to specify other fields in the query syntax:
- Where the status field contains active
status:active
title:(quick OR brown)
title:(quick brown)
- Where the field title has any non-null value:
_exists_:title
Wildcards
Wildcard searches can be run on individual terms, using ? to replace a single character, and * to replace zero or more characters:
qu?ck bro*
Regular expressions
Regular expression patterns can be embedded in the query string by wrapping them in forward-slashes (/):
name:/joh?n(ath[oa]n)/
Fuzziness
We can search for terms that are similar to, but not exactly like our search terms, using the “fuzzy” operator:
quikc~ brwn~ foks~
This uses the Damerau-Levenshtein distance to find all terms with a maximum of two changes, where a change is the insertion, deletion or substitution of a single character, or transposition of two adjacent characters.
The default edit distance is 2, but an edit distance of 1 should be sufficient to catch 80% of all human misspellings. It can be specified as:
quikc~1
Ranges
Ranges can be specified for date, numeric or string fields. Inclusive ranges are specified with square brackets [min TO max] and exclusive ranges with curly brackets {min TO max}.
- All days in 2012:
date:[2012-01-01 TO 2012-12-31]
- Numbers 1..5
count:[1 TO 5]
- Tags between alpha and omega, excluding alpha and omega:
tag:{alpha TO omega}
- Numbers from 10 upwards
count:[10 TO *]
- Dates before 2012
date:{* TO 2012-01-01}
- Curly and square brackets can be combined. E.g. numbers from 1 up to but not including 5:
count:[1 TO 5}
- Ranges with one side unbounded can use the following syntax:
age:>10
age:>=10
age:<10
age:<=10
- To combine an upper and lower bound with the simplified syntax, you would need to join two clauses with an AND operator:
age:(>=10 AND <20)
age:(+>=10 +<20)
Date Time
Dates supplied in the query must follow the ISO-8601 format is YYYY-MM-DD , if there is time then
YYYY-MM-DDThh:mi:ss.SSSZ
Example: 1st April 2011 should take 2011-04-01
Example: 1st April 2011 10:00 AM UTC should be supplied as
2011-04-01T10:00:00.000Z
When supplying the time, colons must be escaped. Query to fetch all records created after 1st April 2011 10:00 AM UTC should be
created_date:>2011-04-01T10\\:00\\:00.000Z
Using Current Date
Often filtering is required to filter data from the beginning of current year/month and so on. The following examples cover such requirements. In this examples $tipo_handle.getDateUtil() gives a date utility that can be used in the following way.
Beginning of Year to Any:created_date:[$tipo_handle.getDateUtil().startOf('year') TO *]
Beginning of Year to Date:created_date:[$tipo_handle.getDateUtil().startOf('year') TO $tipo_handle.getDateUtil().startOf('day')]
Month to Date:
created_date:[$tipo_handle.getDateUtil().startOf('month') TO $tipo_handle.getDateUtil().startOf('day')]
Week to Date:
created_date:[$tipo_handle.getDateUtil().startOf('week') TO $tipo_handle.getDateUtil().startOf('day')]
From Today:
created_date:[$tipo_handle.getDateUtil().startOf('day') TO *}
Till Today:
created_date:{* TO $tipo_handle.getDateUtil().startOf('day')]
Grouping
Multiple terms or clauses can be grouped together with parentheses, to form sub-queries:
(quick OR brown) AND fox
Comments
0 comments
Please sign in to leave a comment.