cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Fulltext search in relationships

Hi there,

I'm currently working on a simple schema (Recipe)-[REQUIRES]-(Ingredient).

I'd like to implement fulltext search on recipes with recipes[name, description ...] and ingredients [name] that only returns recipes.

Can't find any example on how to write this type of search index. any idea ?

  • Version: 3.5.8
  • Edition: community

Thanks,

2 REPLIES 2

You can create a fulltext index on the name and description properties of both :Recipe and :Ingredient nodes.

As for how to return results that are only recipes (or only recipes that contain ingredients), you can't get that just from the index, but you can do some matching to get this. You can use a variable-length relationship of *0..1, meaning that the node you start from might be the node that you want, otherwise traverse the relationship to get to the node:

... // assume we did our fulltext search to get the node variable `node`
MATCH (node)<-[:REQUIRES*0..1]-(recipe)
WITH recipe
...

So whether the node from the index is a :Recipe or an :Ingredient you should get the :Recipe node you want.

@andrew.bowman it seems to work ! Thanks