Flex Query Language helps end users to perform customised searches within both user interaces (e.g. FlexMAM) and other Dalet Flex microservices which requires search service. FQL enables you to carry out complex structured searches in Dalet Flex.
In Dalet Flex, you can carry out simple text based searches by simply entering a word or phrase. You can also use the Query Language to help you carry out more complex searches. The syntax that can be used is as follows:
|Logical Operators||`AND` `OR` `!`||Logical operators are used to search for multiple terms simultaneously. Examples: You can search for two different terms using the `OR` / `AND` operator such as: `movie OR film`, `movie AND comedy`.|
|Quotes||`""`||Quotes are used to search for an exact word or phrase. You wrap the word or phrase in quotation marks. Example: `description="city"`.|
|Tilde||`~`||The tilde character supports a "contains" search. This uses phrase matching to search in elastic search. For example, the search query `q=description~"live at midnight"` returns all values that include the exact phrase "live at midnight".|
|Comparison Operators||`>=` `<=` `<` `>`||Equal or greater, equal or lesser, lesser and greater operators are supported.|
|Boosting||`^`||You can boost a term using a caret (cursor) symbol. Example: `description^5=city`. In this example all the assets which have the word city in the description field will be more considered relevant in the search. If a `SORT BY` clause is provided, boosting has no effect.|
|Brackets||`(` `)`||Examples: `description=(European City)`, and `(pollen=yellow AND flower=red) OR flower=pink` vs `pollen=yellow AND (flower=red OR flower=pink)` The first example searches the for the specific terms "European" and "City" within any description fields. The second pair of examples show how bracket precedence can be used in boolean queries as per normal mathematical expectations.|
|Sorting||`SORT BY` `ASC`/`DESC`||Enables you to sort by a given field. This includes sorting in ascending and descending order. If you do not specify an order, it will sort in ascending by default.|
AND and OR
All queries can be combined with boolean logic using AND and OR, using brackets where necessary to indicate precedence. In the absence of brackets, boolean operations are left-to-right associative, without preferring either `AND` or `OR`, i.e.:
- `A OR B AND C` is the same as `(A OR B) AND C`
- `A AND B OR C` is the same as `(A AND B) OR C`
Multi-OR for a single field:
If you want to match a given field for a range of possibilities (like an `IN` operation in SQL) then an operation like `field=value1 OR field=value2 OR field=value3` will not generate the most efficient Elasticsearch query under the hood.
Instead, we recommend this syntax: `field=(value1 OR value2 OR value3)`.
|`Dalet Flex`||Matches any objects with 'Dalet' and 'Flex' in any order.|
|`"Dalet Flex"`||Since this is quoted, the order does matter. Only objects with the words "dalet flex" adjacent and in that order will be returned.|
|`Dalet Fl?x MAM`||Matches any objects with 'Dalet', 'Fl?x' ('?' matches any single character) and 'mam', in any order.|
|`Dalet F*x MAM`||Same as above however, `*` matches 0 to many characters.|
|`"Dalet Flex asset manage?ent"`||Since this is quoted, the order matters. Only objects matching this exact order will be returned. `?` matches a single character.|
|`"Dalet ? asset management"`||A `?` on its own is used to represent a single word. Only objects containing 'Dalet' exactly one word apart from 'asset management' will be returned.|
|`"Dalet * management"`||A `*` on its own is used to represent many words. If 'Dalet' appears before 'management', the object will be returned.|
Equality searches (text, numeric, or date fields)
|`"name" = "panther"`||The name field is exactly "panther"|
|`!("name" = "panther")`||The name field is not "panther"|
|`name = "panther"`||Any field called name (regardless of path - could be a metadata field, for example) is exactly "panther"|
|`"id" = 12345`||The id field matches 12345|
|`"created" = "2020-10-01"`||The created field matches any UTC time midnight-midnight on the 1st October 2020|
|`"created" = "2020-10-01 10:59:05"`||The created field matches the exact UTC time 10:59:05 on the 1st October 2020|
|`"created" = 1601536528000`||The created field matches the exact UTC time of 1601536528000 milliseconds (i.e. 7:15:28 on on the 1st October 2020)|
|`"taxonomy.10027681" = 10125635/6124797/6124805`||The Location taxonomy matches the India / Gujarat / Ahmedabad hierarchy (using the ids corresponding to the taxonomy and the taxons for the query)|
|`"metadata-1370.new-text-1" = "fred"`||The text metadata field identified by new-text-1 - in MD definition with entity ID 1370 - is exactly "fred"|
|`"new-text-1" = "fred"`||The text metadata field identified by new-text-1 - in any metadata definition - is exactly "fred"|
|`"new-md-field" = "fred"`||The metadata field identified by new-md-field - of any metadata field type, and in any metadata definition - is exactly "fred"|
|`metadata-1.drill-down = ("project1" AND "project2")`||The metadata drill-down field is a list containing both "project1" AND "project2"|
|`metadata-1.drill-down = ("project1" OR "project2")`||The metadata drill-down contains "project1" OR "project2"|
|`!(metadata-1.drill-down = ("project1" AND "project2"))`||The metadata drill-down is neither "project1" OR "project2"|
When searching date fields, the date should be written in the format `yyyy-MM-dd HH:mm:ss` or `yyyy-MM-dd` surrounded by double quotes. E.g. lastModified="2017-06-22 10:24:05"
Contains searches (text fields only)
Note that there is no logical difference between quoting the value part of a Contains search, except that quoting it may help if your query contains other FQL operators, e.g. "sort by", "or", "and", "=", "(", ")", "!", "^", ">", "<", "~".
|`"name" ~ mario`||The name field contains "mario"|
|`"name" ~ m*o`||The name field contains any string starting with "m" and ending in "o"|
|`"name" ~ "mario sort by id"`||The name field contains "mario sort by id"|
|`"name" ~ mario sort by id`||The name field contains "mario"; results are sorted by ID, ascending|
You can boost results by using the carat character ^, which boosts any matching objects in the results. For example, in the example below you would get all objects whose name contains "film from partner" or is an image asset, but the image asset objects will appear higher in the search results.
`name~"film from partner" OR objectType.name^2=image-asset`
You can search on example values using NULL.
Metadata field matching
Searching on the name of a metadata field will match objects referencing any metadata definition with a field of that name. e.g. If 2 metadata definitions exist, both with a field called "string-field", the FQL `string-field=somevalue` would match objects using either of those definitions.
In order to target a specific metadata definition in this case, you need to know the ID of the metadata definition, and then perform a search using FQL like `"metadata-<definitionid>.string-field"=somevalue`.
|`New`||All objects that have "New" in any field|
|`assetOrigin=New`||All assets with an origin of "New"|
|`assetOrigin=New AND objectType.name=media-asset`||All media assets with an origin of "New"|
|`created > "2019-08-22"`||Any object created after 22nd August 2019|
|`!ownerId=5`||Any object not owned by user with ID 5|
|`(name~film OR name~placeholder) AND objectType.name=media-asset SORT BY created DESC`||Any media assets whose name contains "film" or "placeholder", ordered in descending created date order|
|`"name" = "*ther"`||The name field ends with "ther"|
|`"name" = "p*r"`||The name field starts with "p" and ends with "r"|
|`"name" = "b* p?n*"`||would match e.g. "black panther" or "big panda"|