Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Query via JSON #33

Open
Jeremy-Unruh-CK opened this issue May 30, 2018 · 5 comments
Open

Create Query via JSON #33

Jeremy-Unruh-CK opened this issue May 30, 2018 · 5 comments
Assignees

Comments

@Jeremy-Unruh-CK
Copy link

I just started playing with bolthold this evening and it was quick and easy to setup. Really digging it so far.

Maybe this is already supported, but is there any way to construct a *Query via JSON? I would make for a nice search capability on a REST endpoint I'm considering. Since it would allow a query via json to be passed and evaluated.

I could come up with my own mechanism but would take some work to map into the fluent aspects of the current Query with the hidden internals.

@timshannon
Copy link
Owner

There's no support for this yet. Shouldn't be too hard to add though.

@timshannon timshannon self-assigned this May 30, 2018
@ghost
Copy link

ghost commented Aug 25, 2018

i would really like to be able to do this.

For me, the intent is to allow others to write queries without recompiling.
I assume that the go types already need to be in the code though ?

@timshannon
Copy link
Owner

Yeah the types would have to be in code. The way I'm picturing this is a Function call QueryFromJSON or something, and you'd pass in something like this:

{
  "field": "Name",
  "op": "eq",
  "value": "John",
  "and": {
    "field": "ID",
    "op": "ge",
    "value": 3
  },
 "or": {
    "field": "Death",
    "op": "lt",
    "value":  {
      "field": "Birth", 
    }
  }
}

@ghost
Copy link

ghost commented Sep 17, 2018

hey @timshannon. That looks like a good start.

Just as a side thought, I was wondering if its possible to write a query in golang and then just deserialize it out as JSON ? This would mean that you could gen the json as part of the build and then run the JSON as tests. Its also means that when you add new query predicates of your own the system is self adapting. If this is not possible its fine, but it was more of an idea.

Edit: This reminds me a lot of Bleve and the JSON based blast.
https://github.com/mosuka/blast
Blast wraps bleve so that you can just use JSON to query bleve. It also nicely manages the cluster of bleve indexes spread around.
He uses GRPC to expose everything.
The reason i am bringing it up is because its a nice model for BoltHold maybe if you every wanted to expose it as a service.

@ghost
Copy link

ghost commented Sep 17, 2018

@timshannon found this
https://github.com/Cistern/cistern/blob/master/internal/query/query.go

the queries as serialisable :)
Might be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants