Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-29-2019 02:21 AM
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 ?
Thanks,
07-29-2019 11:21 AM
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.
All the sessions of the conference are now available online