https://github.com/yoav-lavi/leita
A universal search query language that can transpile into specific search provider syntax
https://github.com/yoav-lavi/leita
lexer query rust search transpilation universal
Last synced: 11 months ago
JSON representation
A universal search query language that can transpile into specific search provider syntax
- Host: GitHub
- URL: https://github.com/yoav-lavi/leita
- Owner: yoav-lavi
- License: mit
- Created: 2022-01-08T13:33:52.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-14T17:23:24.000Z (over 4 years ago)
- Last Synced: 2025-03-18T07:44:20.043Z (over 1 year ago)
- Topics: lexer, query, rust, search, transpilation, universal
- Language: Rust
- Homepage:
- Size: 67.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Leita 
A universal search query language that can transpile into specific search provider syntax (currently only Google syntax is supported)
A personal project to explore Rust and lexers
## Name
Leita means _"to seek"_ or _"to search"_ in Old Norse and many descendant languages
## Install
### Cargo
Clone this repository and run the following command in the repository root:
```sh
cargo install --path .
```
## Usage
```sh
leita
```
## Syntax
| **Concept** | **Leita** | **Google** | **DuckDuckGo** | **Stack Overflow** | **GitHub** |
| ------------- | ------------------------------------ | ------------------------------- | ---------------- | -------------------------- | ----------------------- |
| exact | "term" | "term" | "term" | "term" | |
| and | first & second | first AND second | | | |
| or | first \| second | first OR second | | \[first\] OR \[second\] | |
| not | !term | \-term | | \-term | NOT term |
| one of | (first \| second \| third) | (first OR second OR third) | | | |
| wildcard | first * second | first * second | | | |
| numeric range | start-end | start..end | | start..end | start..end |
| distance | first ~count second | first AROUND(count) second | | | |
| escaped | \token | | | | |
| more | | | +term | | |
| less | | | -term | | |
Notes:
- Only Google syntax is supported at the moment, other syntaxes added as examples
- Google supports `|` in place of `OR`
- Stack Overflow supports wildcards, but only inside a word
### Examples
- `(dog | cat | wolf | yeti) shampoo 2021-2022 "great!" !lavender home-made` → `(dog OR cat OR wolf OR yeti) shampoo 2021..2022 "great!" -lavender home-made`
- Tokens in quotes need not be escaped
- Ranges are `number-number` only
- `good ~5 dog` → `good AROUND(5) dog`
## Not Supported
- At the moment an exact term (`"term"`) cannot have escaped quotes (`"\"term\""`)
## Acknowledgements
Leita uses the following:
- [Logos](https://github.com/maciejhirsz/logos)
- [Clap](https://github.com/clap-rs/clap)
Assets:
- The search icon is from [Heroicons](https://heroicons.com)