I have two related questions: Is there a formal gr...
# community-help
o
I have two related questions: Is there a formal grammar for
filter_by
or any of the search parameters? I am working on a complex query system which takes a query language, validates and parses it, then constructs typesense queries from the syntax tree. Doing this without knowing the precise filtering grammar (or other params) is quite a challenge. At the moment I've taken all the documented examples and tried to formalise them into PEG and BNF grammars but I would love to be more confident that it matches. Second (much more mundane) question, is there any way to programmatically get a collections schema? I'm using the schema to inject some more intelligent behaviour into the query system so that things like filtering
tags[] > 5
throws a useful syntax error in the frontend. I can copy-paste the schema when it changes but I would really love to avoid that.
I would also love to know if there's some list of syntactically valid filters somewhere, at least that way I could build out a test suite for the filtering grammar
j
We don’t have a formal grammar documented anywhere. But here’s all the possible options written out here under
filter_by
in this table
o
Yeah that's the reference I've been using
j
is there any way to programmatically get a collections schema?
Yup. Using this GET endpoint
🙏 1
o
Any insight into how the filters are parsed? I couldn't find much searching the repo
j
We tried a grammar-based codegen approach, but it became to unwieldy to manage the generated code, so we built our own light-weight parser
o
Gotcha, is that parser public?
o
Awesome, this is great reference, thanks!
👍 1
o
Sweet
For client libraries is there any existing support (or interest in) clientside query validation?
j
No, we validate only the server-side
o
Cool, if I end up producing something interesting or useful I'll share it here, having realtime feedback for complex typesense queries has been really enjoyable for the project I'm working on, might be for others too.
j
That would be great! I’m really curious to see what you’re building!
o
Yeah I look forward to sharing! If deadlines are hit it will be a month, so expect me back here in 2!
🙌 1