Is it possible to create fulltext indexes on all nodes?

CALL db.index.fulltext.createNodeIndex("titlesAndDescriptions",["Movie", "Book"],["title", "description"])

If my graph have lots of node types and each one has a 'name' property, can I create full text index on all nodes with one command? Something like:

`CALL db.index.fulltext.createNodeIndex("nameIndex",[],["name"])`

Failed to invoke procedure `db.index.fulltext.createNodeIndex`: Caused by: java.lang.IllegalArgumentException: Schema descriptor must have at least one label.

Hello @lingvisa :slight_smile:

The first solution I see is to specify all labels, the list of labels cannot be empty :slight_smile:


@Cobra is right, fulltext indexes are always based on labels or relationshipTypes plus properties.
Assuming each of you nodes does have a label (aka you don't have unlabeled nodes) you could do easily collect all the labels you have and build a index on that collection:

call db.labels() yield label with collect(label) as labels
call db.index.fulltext,createNodeIndex("nameIndex", labels, ["name"]) 

That's true. In code it's simple to do. A related question regarding fulltext query. Since it directly searches on dedicated indexes, rather than regular properties, so it doesn't speed up to add MATCH ... WHERE clause to CALL clause:

MATCH (n:Product)
WHERE n.price<1000
CALL db.index.fulltext.queryNodes("titleIndex", "title") YIELD node, score
RETURN node.title, score

MATCH ... WHERE shouldn't be used here?

Yes you can directly start with:

CALL db.index.fulltext.queryNodes("titleIndex", "title") YIELD node, score


@Cobra, my question is, add the usual MATCH and WHERE clause to fulltext queries won't help performance for fulltext queries. Right?

No, it won't help, it's useless.