考虑以下课程:
class Basic{
String id;
Double val;
//some other member variables
}
class NodeBO{
List<String> id;
Type type;
// list of id from objects of Basic class in data below
Map<ChEnum, Basic> data;
addBeans(NodeBO nodeBO, Node node){
// in transaction...
node.setProperty("priperties", nodeBO.toString());
// is it ok to convert to array? or should be converted to JSON string?
node.setProperty(GraphElementProps.id,toArray(nodeBO.id));
node.setProperty(GraphElementProps.type, nodeBO.type);
}
@override
toString(){
//return json of this object
}
}
enum ChEnum{
CH1(1), CH2(2);
// constructor and some methods
}
使用autoIndexer索引节点:
AutoIndexer<Node> nodeAutoIndexer = GRAPH_DB.index().getNodeAutoIndexer();
nodeAutoIndexer.startAutoIndexingProperty(GraphElementProps.id);
nodeAutoIndexer.setEnabled(true);
GRAPH_NODE_AUTO_INDEX = nodeAutoIndexer.getAutoIndex();
这里我将GraphElementProps.id
存储为节点属性(通过转换为数组)。是否将数组(字符串)作为属性?或者我应该将列表转换为JSON字符串,然后存储?
我希望能够使用queryId
查询此数组。例如查询node-index以获取node.getProperty(GraphElementProps.id)
包含给定queryId
的节点?例如:
// how to do this?
GRAPH_NODE_AUTO_INDEX.get(/*Nodes whose id contain queryId*/);
或者(以某种方式)是否可以使id
类的Basic
属性可索引和可搜索?如果可能,如何索引这些属性?以及如何查询它们?
我无法理解,但它与Spring-data-neo4j
有关吗?我是Spring-data-neo4j
的新手。