neo4j and java collection search -


hi i'm trying search using operator in, return empty list, wrong ? bellow unit test. whta want search product descriptio or similarity word macths description. (futurely pretend implement fuzzy).

private graphdatabaseservice graph; private index<node> indexproduct; private executionengine engine;  @before public void preparetestdatabase() {     testgraphdatabasefactory testgraphdatabasefactory = new testgraphdatabasefactory();     this.graph = testgraphdatabasefactory.newembeddeddatabase("/tmp/neo4j/tests");     this.indexproduct = this.graph.index().fornodes("node_product");     this.engine = new executionengine(this.graph, stringlogger.system);     this.loaddatafortest(); }  private void loaddatafortest() {     transaction tx = this.graph.begintx();      list<string> similarities = new arraylist<>();     similarities.add("televisor");     similarities.add("tv");     string description = "televisão";     product product = new product(description, similarities);      node node = this.graph.createnode(dynamiclabel.label(product.description));     node.setproperty("description", product.description);     node.setproperty("similarities", product.similarities);      this.indexproduct.add(node, "product", product.description);      tx.success();     tx.finish(); }  @test public void searchbydescription(){     string description = "televisão";      list<string> list = new arraylist<>();     executionresult result = this.engine.execute("start n=node:node_product('product:*') has(n.similarities) , n.similarities in ['tv'] return n.description");     (map<string, object> row : result) {         (entry<string, object> column : row.entryset()) {             object value = column.getvalue();             list.add(string.valueof(value));         }     }      assert.asserttrue(list.contains(description)); } 

this product class

class product {     string description; string[] similarities;  product(string description, list<string> similaritieslist) {     super();     this.description = description;     this.similarities = new string[similaritieslist.size()];     (int i=0; i<similaritieslist.size(); i++)         this.similarities[i] = similaritieslist.get(i); } 

i hope got usecase right. think there's little confusion in cypher query. query:

"start n=node:node_product('product:*') has(n.similarities) , n.similarities in ['tv'] return n.description" 

lets have on n.similarities in ['tv']. property similarities array. ['tv'] an array of strings. thus, expression `n.similarities in ['tv'] evaluates false because ['tv'] not contain arrays, let alone similarities array.

in end figure meant else, viz.

 'tv' in n.similarities 

could right? want check whether string tv contained in similarities array. when change query way, i.e. resulting query be

start n=node:node_product('product:*') has(n.similarities) , 'tv' in n.similarities return n.description 

then, adapted test class works me.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -