Filtering on same predicate using multiple indices

Hi,

Has anyone tried filtering on the same predicate using different indices? The query I used returned a subset of the results I was expecting.

E.g.

Mutation:

{
    set {
        _:a <name> "Foo Edit" .
        _:a <dgraph.type> "User" .

        _:b <name> "Foo Edit1" .
        _:b <dgraph.type> "User" .

        _:c <name> "Ba" .
        _:c <dgraph.type> "User" .

        _:d <name> "Bar" .
        _:d <dgraph.type> "User" .

        _:e <name> "Barry" .
        _:e <dgraph.type> "User" .
    }
}

Schema:

<name>: string @index(term, trigram) .

Query:

{            
    q (func: type("User")) @filter(anyofterms(name, "foo") OR match(name, "ba", 5)) {
        name
      }
}

Expected results: All 5 nodes
Actual results: nodes for (“Ba”, “Bar”, “Barry”)

Let me know if this is expected behavior or if this is a bug. Thank you.

1 Like

Which Dgraph version are you using?

I’m using the latest docker image.

alpha_1  | Dgraph version   : v20.03.3
alpha_1  | Dgraph SHA-256   : 08424035910be6b6720570427948bab8352a0b5a6d59a0d20c3ec5ed29533121
alpha_1  | Commit SHA-1     : fa3c19120
alpha_1  | Commit timestamp : 2020-06-02 16:47:25 -0700
alpha_1  | Branch           : HEAD
alpha_1  | Go version       : go1.14.1alpha_1  | Dgraph version   : v20.03.3
alpha_1  | Dgraph SHA-256   : 08424035910be6b6720570427948bab8352a0b5a6d59a0d20c3ec5ed29533121
alpha_1  | Commit SHA-1     : fa3c19120
alpha_1  | Commit timestamp : 2020-06-02 16:47:25 -0700
alpha_1  | Branch           : HEAD
alpha_1  | Go version       : go1.14.1

Something fishy is definitely happening there. I get different results for the same code:

Could it be because the indexing is not complete? Let me check.

I was working with another engineer on this and he reported weird results as well. The results would change every now and then. We decided to pull the latest image and the results were more consistent, but definitely not what we would expect.

Hey, thanks for bringing up the problem. We have identified the issue and are working on a solution.

Should I file an issue on github?

Yes, please go ahead.

Opened one for you: Filtering on same predicate using multiple indices give unexpected result · Issue #5812 · dgraph-io/dgraph · GitHub, we will take a look.

1 Like

Thanks. :slight_smile: