Error: Predicate name is not indexed

This works and outputs lots of nodes.

{
  yo(func: has(name)) {
    name
  }
}

But the query below is giving me error Predicate name is not indexed. I am trying to search for a node with name attribute as Observation_WindDirection_4UT01_2004_8_13_19_45_001.

{
  yo(func: eq(name, "Observation_WindDirection_4UT01_2004_8_13_19_45_001")) {
    uid
  }
}

eq query requires indexing on the predicate which you want to query on. From the docs:

Index Required: An index is required for the eq(predicate, ...) forms (see table below) when used at query root. For count(predicate) at the query root, the @count index is required.

Try adding following to your schema file
<name>: string @index(exact) . .

Now is possible to use filters without indexing.

e.g

{
  yo(func: has(name)) @filter(eq(name, "Observation_WindDirection_4UT01_2004_8_13_19_45_001")) {
    name
  }
}

That should work

btw, that approach isn’t better than indexing the predicate. Has func is a wide range query. Which can take too long sometimes.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.