# Filtering on same predicate using multiple indices

**URL:** <https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502>\
**Category:** Dgraph\
**Created:** [July 2, 2020, 7:17pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502 "2020-07-02T19:17:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![drefined](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/drefined/32/3689_2.png) [@drefined](https://discuss.dgraph.io/u/drefined)\
**Post date:** [July 2, 2020, 7:17pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/1 "2020-07-02T19:17:48Z")

</div>

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:

```auto
{
    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:

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

```

Query:

```auto
{            
    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.

---

<div class="post-metadata">

**Author:** ![Anurag](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anurag/32/2599_2.png) [@Anurag](https://discuss.dgraph.io/u/Anurag)\
**Post date:** [July 2, 2020, 7:21pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/2 "2020-07-02T19:21:30Z")

</div>

Which Dgraph version are you using?

---

<div class="post-metadata">

**Author:** ![drefined](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/drefined/32/3689_2.png) [@drefined](https://discuss.dgraph.io/u/drefined)\
**Post date:** [July 2, 2020, 7:22pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/3 "2020-07-02T19:22:05Z")

</div>

I’m using the latest docker image.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Anurag](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anurag/32/2599_2.png) [@Anurag](https://discuss.dgraph.io/u/Anurag)\
**Post date:** [July 2, 2020, 7:36pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/4 "2020-07-02T19:36:11Z")

</div>

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

 ![Screenshot1593718497](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/5/560d0439fe4d57021c2216a0996bbfdf8149b93e.png)

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

---

<div class="post-metadata">

**Author:** ![drefined](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/drefined/32/3689_2.png) [@drefined](https://discuss.dgraph.io/u/drefined)\
**Post date:** [July 2, 2020, 7:49pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/5 "2020-07-02T19:49:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![harshil\_goel](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/harshil_goel/32/3737_2.png) [@harshil\_goel](https://discuss.dgraph.io/u/harshil_goel)\
**Post date:** [July 2, 2020, 8:10pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/6 "2020-07-02T20:10:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drefined](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/drefined/32/3689_2.png) [@drefined](https://discuss.dgraph.io/u/drefined)\
**Post date:** [July 2, 2020, 8:16pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/7 "2020-07-02T20:16:35Z")

</div>

Should I file an issue on github?

---

<div class="post-metadata">

**Author:** ![Anurag](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anurag/32/2599_2.png) [@Anurag](https://discuss.dgraph.io/u/Anurag)\
**Post date:** [July 2, 2020, 9:04pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/8 "2020-07-02T21:04:36Z")

</div>

Yes, please go ahead.

---

<div class="post-metadata">

**Author:** ![Anurag](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anurag/32/2599_2.png) [@Anurag](https://discuss.dgraph.io/u/Anurag)\
**Post date:** [July 3, 2020, 8:54am UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/9 "2020-07-03T08:54:14Z")

</div>

> [@drefined](#):
>
> Expected results: All 5 nodes  
> Actual results: nodes for (“Ba”, “Bar”, “Barry”)

Opened one for you: [Filtering on same predicate using multiple indices give unexpected result · Issue #5812 · dgraph-io/dgraph · GitHub](https://github.com/dgraph-io/dgraph/issues/5812), we will take a look.

---

<div class="post-metadata">

**Author:** ![drefined](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/drefined/32/3689_2.png) [@drefined](https://discuss.dgraph.io/u/drefined)\
**Post date:** [July 3, 2020, 3:42pm UTC](https://discuss.dgraph.io/t/filtering-on-same-predicate-using-multiple-indices/7502/10 "2020-07-03T15:42:38Z")

</div>

Thanks. 🙂
