1

ノードとリレーションシップを 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()andに渡そうとしたことindex.add()です。前者は、必要ValueContextがなく、理解していないため、クラッシュしていました。したがって、これらのメソッドに異なるプロパティ マップを渡して、ValueContext-ed 数値を対象のメソッドに含めるようにしてindex.addください。

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));
4

1 に答える 1

0

どのバージョンの neo4j を使用していますか? 最新のリリースで動作しています

于 2011-08-09T07:27:30.847 に答える