[英]Numeric index during batch insertion in Neo4j
我正在將節點和關系的批處理插入Neo4j圖形數據庫中。 一切正常,包括多個屬性的索引([String] name, [int] id)
。 但是,當我嘗試按范圍查詢屬性“ id”的索引時,它不返回任何結果。
從非批處理示例派生出來的問題是,我無法像這樣將數字ValueContext
給BatchInserterIndex
:
Map<String, Object> properties = new HashMap<String, Object>(2);
properties.put("name", urs.getString(1));
// I can do this:
properties.put("id", urs.getInt(2));
// But not this (throws an "invalid type" exception):
// properties.put("id", new ValueContext( urs.getInt(2) ).indexNumeric());
long node_id = inserter.createNode(properties);
index.add(node_id, properties);
在批處理插入期間,我還沒有找到任何有關數字索引的文檔 。
查詢代碼如下:
IndexManager index = gdb.index();
Index<Node> people = index.forNodes("people");
IndexHits<Node> hits = people.query(
QueryContext.numericRange("id", min_id, max_id)
);
是否可以在批處理插入操作中添加數字索引,以便隨后可以按范圍查詢值?
謝謝。
我做錯的是我試圖將相同的屬性映射傳遞給createNode()
和index.add()
。 前者崩潰了,因為它不需要ValueContext
並且不理解它。 因此,請確保將不同的屬性映射傳遞給這些方法,並在用於index.add
值中包含ValueContext
-ed數值:
Long value = 1L;
long node_id = inserter.createNode(
MapUtil.map("id", value, "other_prop", other_value));
index.add(node_id,
MapUtil.map("id", ValueContext.numeric( value ), "other_prop", other_value));
您正在使用哪個版本的neo4j? 它正在最新版本中運行
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.