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

Question. QueryPolicy.filterExp is use by 2nd index? #189

Open
boojongmin opened this issue May 4, 2021 · 2 comments
Open

Question. QueryPolicy.filterExp is use by 2nd index? #189

boojongmin opened this issue May 4, 2021 · 2 comments

Comments

@boojongmin
Copy link

boojongmin commented May 4, 2021

I read this #33

but I need search multiple bin with index.

aerospikeClient.createIndex(
    null, "hello", "hello",
    "idx_1", "hello1", IndexType.STRING,
    IndexCollectionType.DEFAULT
).awaitFirstOrNull()

aerospikeClient.createIndex(
    null, "hello", "hello",
    "idx_2", "hello2", IndexType.STRING,
    IndexCollectionType.DEFAULT
).awaitFirstOrNull()


val policy = QueryPolicy()
policy.filterExp = Exp.build(
        Exp.and(
            Exp.eq(Exp.bin("hello1", Exp.Type.STRING), Exp.`val`("asdf")),
            Exp.eq(Exp.bin("hello2", Exp.Type.STRING), Exp.`val`("defg"))
        ),
)

val v = aerospikeClient.query(policy, statement).awaitFirstOrNull()

is this code will use index?

and... how I know search rules like sql explain

thank you

@BrianNichols
Copy link
Member

There is still a limit of one index filter (statement.setFilter()) per query, so either "idx_1" or "idx_2" could be used, but not both.

Expression filters (policy.filterExp) are applied after the index is used and can reference any combination of bins in the returned record. Therefore, your code should work, but only one index will be traversed.

@boojongmin
Copy link
Author

@BrianNichols thank for your appreciate comment. It is many helps for me. :)

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

No branches or pull requests

2 participants