2013-07-11 65 views
0

考慮以下類:查詢上數組屬性或嵌入屬性

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.getProperty(GraphElementProps.id)包含的節點queryId?即是這樣的:

// how to do this? 
GRAPH_NODE_AUTO_INDEX.get(/*Nodes whose id contain queryId*/); 

或者是它(在某種程度上)可能使Basicid財產可轉位和可搜索?如果可能,如何索引這些屬性?以及如何查詢它們?

我無法理解,但它是否與Spring-data-neo4j有關?我對Spring-data-neo4j完全陌生。

回答

0

我認爲最好的解決方案是使用Spring-data-neo4j。這將允許索引嵌入字段並對它們進行查詢。