vaticle / typeql

TypeQL: the polymorphic query language of TypeDB
https://typedb.com
Mozilla Public License 2.0
213 stars 45 forks source link

Introduce `in` predicate to check against a set of values #213

Open maydanw opened 3 years ago

maydanw commented 3 years ago

Problem to Solve

Concrete example:
Given a list of 1000s of document entities ids retrieved from a search in ES we want to check if a user has access to each of them and filter them. The current options are either:

  1. Running 1000s of independent queries
  2. Build a query with 1000s of independent OR statements

Both are inefficient

Current Workaround

  1. Running 1000s of independent queries
  2. Build a query with 1000s of independent OR statements

Proposed Solution

Add "in" (or "isIn") construct to the syntax
For example (in python):

query = "match $d isa document, has objID in ["123", "1122", "333AAA", "6A5B"]; ..."

Additional Information

Beyond improving the ease of usage, I (@maydanw) believe this can be optimized due to:

flyingsilverfin commented 1 year ago

This might naturally be incldued in the future when we include vectors or sets of values natively in TypeDB?

related: https://github.com/vaticle/typedb/issues/6327

flyingsilverfin commented 1 year ago

Related to https://github.com/vaticle/typedb/issues/5527