Custom parsing of a search query

Greetings everyone!

I’ve been working on some projects, one of them is going to be an open source platform for researchers to share pharmacokinetic data. The basics of the platform are done, now I’m thinking about the search mechanism.

I would like to write a system that enable researchers to compose queries, something like this. In that web a search string like this year>1998 year<2020 c:r t:cat or t:fish name:"Hippo" would give us this.

I was going to start writing something like that for my project, but then I realized that I might not been the first person with this kind of problem. That’s why I’m here, Do any of you know some library or pattern that would help me to implement this?

I did a basic search over internet and my results were scarce. Right now I think that it’s very specific and I would need to implement it by myself :sweat_smile:


1 Like

The only solution that comes to my mind is to implement a DSL using PEG, LALR or similar.


We use nimble_parsec. You can take a look at what we’ve done with our parser. We’ve got a fairly robust query language for searching through structured logs.

You can do something like (this is on the staging branch to roll out to prod this week):

Note: while not open source I wanted to keep Logflare public for some more complete Elixir examples. Hopefully this is helpful.


@Vesuvium and @chasers the resources provided are very helpful indeed.

Thank you very much!

1 Like