Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-19-2018 02:04 AM
Neo4j query:
MATCH p=()-[r:HasCustomer]->() where r.numer_of_visits >= 2 and r.numer_of_visits < 4 AND r.merchant_id = 428
RETURN r.customer_id
Started streaming 692246 records after 2 ms and completed after 13800 ms, displaying first 1000 rows.
Mysql Query
SELECT customer_id FROM customers_merchant_map
where merchant_id = 428 and numer_of_visits >=2 and numer_of_visits <4
Showing rows 0 - 24 (692402 total, Query took 0.0019 seconds.)
How to optimize this query time ?
09-19-2018 04:11 AM
Neo4j's schema index doesn't currently support indexed relationship properties.
While there is a way to leverage the older lucene explicit index to create an index of relationship properties, it's entirely manual, so it's up to you to update the index whenever relationships of the given type are added or removed or the properties changed.
We instead recommend refactoring your model. If you need to perform an index lookup of something, that usually suggests that thing would be better modeled as a node. As a node you are able to create the indexes and constraints you need for quick lookup.
At the very least, merchant_id
suggests you should have a :Merchant node in your graph with a unique id.
11-26-2019 07:39 AM
Hello,
This topic is from a year ago. I was wondering if indexing on relationship properties is something that is on the backlog and is actively being considered as a feature?
Thanks for an update.
12-02-2019 03:22 PM
As of Neo4j 3.5 we have fulltext schema indexes, which can be applied on relationships. These are implemented via procedure calls, and for relationships you can specify the relationship types you want to index, and the properties of the relationships to be included in the index. These are limited to strings at this point in time.
You can then query the fulltext schema index by the name you used when the index was created, and you'd get back results as well as the score of the result (which you can filter on to get rid of inaccurate results). This is a case insensitive index lookup, and you can additionally use lucene analyzers to have more custom behavior.
10-21-2020 01:27 AM
Hi Andrew,
Just checking if there are any updates on this? I'm running some analysis queries that filter based on numerical and date properties of a relationship. Is there a way to index these?
Thanks!
10-21-2020 06:29 AM
No, not currently. We would advise refactoring your model such that nodes have the relevant numerical or date properties, and add an index on them instead.
All the sessions of the conference are now available online