--- last_review: "2025-01-01" last_reviewer: "-" documented_code: [ ] --- ```{tags} user, how-to ``` # How to search data in LinkAhead # ```{contents} Table of Contents :depth: 2 :local: ``` ## How to find your data? ## To find specific data sets in LinkAhead, open the query panel by clicking on the query item in the top menu bar. Here you can enter search commands, or queries, using the LinkAhead query language (LQL). A query always begins with a keyword. There are three keywords you can choose from: - `FIND` displays {term}`entities ` that match specific criteria - `COUNT` returns the number of {term}`records ` that meet certain conditions - `SELECT` specifies which fields or columns to include in the output For more information, have a look at - the other sections on this page, - the [search tutorial](/tutorial/webinterface/query_find.md) - or the [in-depth query explanation](/explanation/general/linkahead_query_language.md). ## Search by RecordType ## To get all Record entries of a specific {term}`RecordType`, search with `FIND {name of RecordType}`. For example, to find all stored `Sample` records, write in the query field: ```lql FIND Sample ``` If you are interested only in the number of records, use `COUNT` instead of `FIND`: ```lql COUNT Sample ``` ## Search for data schema components ## If you are not interested in records, but instead want information about the data {term}`schema `, try searching for RecordTypes instead of records (the default): ```lql FIND RECORDTYPE Machine ``` This returns the `Machine` RecordType and all RecordTypes which inherit from it. RecordTypes can also be found by their {term}`Properties `: ```lql FIND RECORDTYPE WITH latitude ``` Similarly, you can also search for Property entries: ```lql FIND PROPERTY production_date ``` ## Search by text ## Sometimes you want to search for a specific text. In this case, you can shorten the search input. Simply put the text you are looking for in the query field: ```lql Nice ``` This will return all records which - have `Nice` in their name, - have `Nice` in one of their Property values, - or reference another Record which has `Nice` in its name. ## Search for Record with a Property ## You can find records that have a {property regardless of whether the value for the property is set or not. To retrieve any records with {term}`Parent` "Manufacturer" which have a Property "address": ```lql FIND Manufacturer WITH "address" ``` :::{admonition} Note :class: note dropdown Due to [an issue](https://gitlab.com/linkahead/linkahead-server/-/work_items/231) with the query parsing, LinkAhead requires `address` to be in quotes here, because otherwise it would interpret the query as `... WITH A ddress`. This will change once the issue has been fixed. ::: It does not matter what the address looks like, LinkAhead returns all manufactures which have *any* address. This also works for linked properties: ```lql FIND Manufacturer WITH Contact WITH email_address ``` ## Filter the search results by property value ## If you want to search for Records with a certain property that has a certain value (for example a price of at least 100), the general structure of the query is `FIND {RecordType name} WITH {Property name} = {value}`. To find all bicycle frames with a weight of 10kg, type: ```lql FIND Frame WITH weight = 10 kg ``` You can also omit the unit (`weight = 10`) and might then also get miniature frames whose weight is stored as 10g. You can also use the other operators [which are listed in the reference](/reference/general/lql_reference.md), like `!=`, `<=`, `<`, `>=`, and `>`. ## Filter with wildcards ## Wherever you can filter by text, you can instead also filter by text chunks. This works by replacing the `=` by `LIKE` and adding wildcard asterisks `*` to the text chunk: ```lql FIND MusicalInstrument WITH Manufacturer LIKE Gi* ``` and ```lql FIND MusicalInstrument WITH Manufacturer LIKE *bson ``` will both show instruments by the manufacturer `Gibson`. ## Search by date and time ## LinkAhead generally uses the YYYY-MM-DDT00:00:00 datetime format ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)). When searching for dates and times, you can use the following DateTime operators: `=`,`!=`, `<`, `>`, `IN`, and `NOT IN`. Search for an exact date: ```lql FIND Record WITH production_date = 2020-12-02 ``` If you want to search for **all machines produced in a specific year**, modify the query like this: ```lql FIND Machine WITH production_date IN 2020 ``` ## Organize simple data in tables To organize data in tables, use the `SELECT` query. Use it like this: ```lql SELECT {property 1}, {property 2}, [...] FROM {same as FIND query} ``` For example, to get all production dates and manufacturers of machines after 2010, write: ```lql SELECT production_date, Manufacturer FROM Machine WITH production_date > 2010 ``` ## Get data from the network of records, as a table ## When specifying SELECT queries, you can also display linked records' {term}`properties `, by concatenating property names with a `.`: ```lql SELECT production_date, Manufacturer.latitude, Manufacturer.longitude, Manufacturer.Contact.email_address FROM Machine ``` ## Reuse search queries ## Reusing search queries is covered in a different user guide: [How-to: Query shortcuts](./query_shortcut_howto.md)