neo4j-contrib / neo4j-elasticsearch

Neo4j ElasticSearch Integration
Apache License 2.0
210 stars 79 forks source link

Add support for multiple indices, labels and properties #2

Closed jazzido closed 9 years ago

jazzido commented 9 years ago

Hi @jexp,

As I mentioned in #1, I needed a convenient way to keep my ElasticSearch cluster in sync with Neo4J. Taking up where you left off a couple weeks ago, I implemented support for specifying index→label mappings, and property selections. The syntax is a bit different to what you proposed in the README; my version looks like this:

elasticsearch.index_spec=my_index:Label(prop1,prop2),my_other_index:OtherLabel(prop3)

That is, properties prop1 and prop2 of nodes labeled as Label, will be stored in my_index.

Additionaly, the beforeCommit handler in ElasticSearchEventHandler was generating duplicate ElasticSearch actions. To avoid them, beforeCommit now accumulates ES actions in a Map keyed by (indexName, nodeId) instead of a list.

Caveat emptor: I only dabble in Java occasionally, so there might be some unidiomatic code here and there. The tests pass, and this has been working great for the last couple days in a staging instance of my DB, but it should be (stress) tested more thoroughly before using it in production settings.

Looking forward to receiving your feedback!

jexp commented 9 years ago

Perfect thanks a ton. Your contribution is much appreciated.