3

I want to store multiple values in a single index property of neo4j Lucene index, e.g.

IndexName: profile

property- Education: "Stanford University, Grad School", "Harvard University, MS"
property- Work: "Nokia Siemens Networks", "Motorola" 

Search should also work in all cases like and, or.

We can do such a thing with Solr setting the property as multi-valued attribute. I'm not sure about neo4j + Lucene.

makes
  • 6,438
  • 3
  • 40
  • 58
wakeup
  • 495
  • 4
  • 19

1 Answers1

8

You can add String[] array values to an index (just as with nodes/relationships) and it will index each item in the array separately and I think that will solve your problem.

  Index myIndex = graphDb.index().forNodes( "profile" );
  myIndex.add( myNode, "Education", new String[] {"Stanford University, Grad School", "Harvard University, MS"} );
  myIndex.add( myNode, "Work", new String[] {"Nokia Siemens Networks", "Motorola"} );
  // Query for it (remember the quote escaping)
  myIndex.query( "Education:\"Stanford University, Grad School\" AND Work:Motorola" );

That should do it.

Mattias Finné
  • 3,034
  • 1
  • 15
  • 7
  • Thank you for the answer! Took me some time to find this thread and figure it out.. Does it exist in the Neo4j documentation? I did not find anything! – TekTimmy May 28 '14 at 09:43