Storing multiple values in single property of Neo4j Lucene index
-
02-03-2021 - |
Domanda
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.
Soluzione
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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow