Search code examples
redisgraph

Search in all vertices by one specific field value


I would like to know if it's possible to search in all vertices by one specifig field value, without naming each vertex explicitly 🤔


Solution

  • If you do not specify the label it is possible to query all nodes via property.

    Say I have two labels Actors(properties: ActorId and Name) and Movies(properties: tconst and primaryTitle) in a database called IMDB and I want to search for either movies or actors named Kevin Bacon.

    I can query across both node labels. However, if the property names are different this makes little sense and will not utilize the indices.

    > GRAPH.QUERY IMDB "MATCH (a{Name: 'Kevin Bacon'}) RETURN a limit 1"
    1) 1) 1) "a.ActorId"
          2) "a.Name"
          3) "a.tconst"
          4) "a.primaryTitle"
       2) 1) "nm0000102"
          2) "Kevin Bacon"
          3) "NULL"
          4) "NULL"