0
我想索引大型數據庫(〜2000萬個節點)中的節點上的整數字段。我期望工作的行爲如下:neo4j + lucene中的整數索引行爲
HashMap<String, Object> properties = new HashMap<String, Object>();
// Add node to graph (inserter is an instance of BatchInserter)
properties.put("id", 1000);
long node = inserter.createNode(properties);
// Add index
index.add(node, properties);
// Retrieve node by index. RETURNS NULL!
IndexHits<Node> hits = index.query("id", 1000);
我將鍵值對添加到索引,然後通過它查詢。可悲的是,這是行不通的。
我現在的hackish的解決方法是通過範圍內使用Lucene的對象和查詢:
// Add index
properties.put("id", ValueContext.numeric(1000).indexNumeric());
index.add(node, properties);
// Retrieve node by index. This still returns null
IndexHits<Node> hits = index.query("id", 1000);
// However, this version works
hits = index.query(QueryContext.numericRange("id", 1000, 1000, true, true));
這是完美的功能,但範圍查詢是非常愚蠢的。有沒有一種方法來運行確切的整數查詢沒有這QueryContext.numericRange
爛攤子?
如果你廢除了'ValueContext'對象時,此工作更換
index.query("id", 1000)
。你失去了按範圍查詢的能力,但這對我來說無關緊要。 謝謝! – PattimusPrime