Querying on multiple labels and property values appear not to use indexes

Hi

I've been experimenting with Neo4J 3.5.0 and looking at one particular query. My initial work was based on a Gremlin query which was performing badly, and i've now tried several different constructions in Gremlin as well as now trying various forms in Cypher.

The main thing thing is being able to query for different node labels both of which share a common property and additionally checking for values in a list. Given the size of graph, 500M nodes i'd like to have it use indexes (all of which are created) but so far it seems to resort to a FILTER (for the property match) over the matched nodes (from matching the label).

I've tried the simple form:

MATCH (a) WHERE (a:label1 or a:label2 or a:label3) AND a.propName in ['val1','val2','val3'] RETURN count(a)

Then i've tried several different constructions using more elaborate OR and UNION. The closest i've come to is:

MATCH (a:label1) WHERE a.propName in ['val1','val2','val3'] RETURN a
UNION
MATCH (a:label2) WHERE a.propName in ['val1','val2','val3'] RETURN a
UNION
MATCH (a:label3) WHERE a.propName in ['val1','val2','val3'] RETURN a

However this yields a list of nodes rather than the simpler count i was aiming for.

I was looking for any suggestions for getting the simpler type of query working effeciently, or a way to adapt the more verbose query to get a (distinct) count.

Thanks for any help.

Tony

it looks like your query terminates with a ‘with’ clause. This is not allowed. You need to end with a ‘return’ clause. You can optionally add any of the following ‘order by’, ‘skip’, and ‘limit’ after a ‘return’ clause. Replace ‘with’ with ‘return’ to resolve the error.