I have items
graph db. each item
is connected to multiple properties
, which can be shared by multiple items
.
I add a search
node which is defined by few properties
.
So I have (search_node) connected to multiple (properties_nodes) connected to multiple (items_nodes)
Now I would like to get a list of items who answer this search by {x} properties or more. Ordered by number of matching properties.
start se=node:node_auto_index(name = {name}), pr = node:node_auto_index(type="item_property")
MATCH p=(se) -[rt:SEARCH]- > (pr)<-[r]-(item)
WHERE Has(item.type) and (item.type = "item")
WITH item, collect(distinct pr.name) as rs
where length(rs) > {x}
RETURN item.name as item_name, length(rs) as matching_properties
ORDER BY matching_properties desc
The performance issue for me, is that it will search for all matching items, even those who match for only one property, and then remove all the items who are matching less than {x}. If {x} is higher than 1, it's a big waste.
How can I "MATCH" only by {x} matching properties?
Created a matching sample : http://console.neo4j.org/?id=adrgsh
(neo4j version 1.9.2)