コード例 #1
0
 @Test
 public void shouldBeAbleToRemoveNodeFromIndexWithoutKeyValue() {
   String key1 = "kvkey1";
   String key2 = "kvkey2";
   String value = "myvalue";
   String value2 = "myvalue2";
   String indexName = "node";
   long nodeId = graphdbHelper.createNode();
   actions.addToNodeIndex(indexName, key1, value, nodeId);
   actions.addToNodeIndex(indexName, key1, value2, nodeId);
   actions.addToNodeIndex(indexName, key2, value, nodeId);
   actions.addToNodeIndex(indexName, key2, value2, nodeId);
   assertEquals(1, graphdbHelper.getIndexedNodes(indexName, key1, value).size());
   assertEquals(1, graphdbHelper.getIndexedNodes(indexName, key1, value2).size());
   assertEquals(1, graphdbHelper.getIndexedNodes(indexName, key2, value).size());
   assertEquals(1, graphdbHelper.getIndexedNodes(indexName, key2, value2).size());
   actions.removeFromNodeIndexNoValue(indexName, key1, nodeId);
   assertEquals(0, graphdbHelper.getIndexedNodes(indexName, key1, value).size());
   assertEquals(0, graphdbHelper.getIndexedNodes(indexName, key1, value2).size());
   assertEquals(1, graphdbHelper.getIndexedNodes(indexName, key2, value).size());
   assertEquals(1, graphdbHelper.getIndexedNodes(indexName, key2, value2).size());
   actions.removeFromNodeIndexNoKeyValue(indexName, nodeId);
   assertEquals(0, graphdbHelper.getIndexedNodes(indexName, key1, value).size());
   assertEquals(0, graphdbHelper.getIndexedNodes(indexName, key1, value2).size());
   assertEquals(0, graphdbHelper.getIndexedNodes(indexName, key2, value).size());
   assertEquals(0, graphdbHelper.getIndexedNodes(indexName, key2, value2).size());
 }
コード例 #2
0
  @Test
  public void shouldBeAbleToIndexNode() {
    String key = "mykey";
    String value = "myvalue";
    long nodeId = graphdbHelper.createNode();
    String indexName = "node";

    actions.createNodeIndex(MapUtil.map("name", indexName));

    assertFalse(serialize(actions.getIndexedNodes(indexName, key, value)).iterator().hasNext());
    actions.addToNodeIndex(indexName, key, value, nodeId);
    assertEquals(Arrays.asList(nodeId), graphdbHelper.getIndexedNodes(indexName, key, value));
  }
コード例 #3
0
 @Test
 public void shouldBeAbleToFulltextIndex() {
   String key = "key";
   String value = "the value with spaces";
   long nodeId = graphdbHelper.createNode();
   String indexName = "fulltext-node";
   graphdbHelper.createNodeFullTextIndex(indexName);
   assertFalse(serialize(actions.getIndexedNodes(indexName, key, value)).iterator().hasNext());
   actions.addToNodeIndex(indexName, key, value, nodeId);
   assertEquals(Arrays.asList(nodeId), graphdbHelper.getIndexedNodes(indexName, key, value));
   assertEquals(
       Arrays.asList(nodeId),
       graphdbHelper.getIndexedNodes(indexName, key, "the value with spaces"));
   assertEquals(Arrays.asList(nodeId), graphdbHelper.queryIndexedNodes(indexName, key, "the"));
   assertEquals(Arrays.asList(nodeId), graphdbHelper.queryIndexedNodes(indexName, key, "value"));
   assertEquals(Arrays.asList(nodeId), graphdbHelper.queryIndexedNodes(indexName, key, "with"));
   assertEquals(Arrays.asList(nodeId), graphdbHelper.queryIndexedNodes(indexName, key, "spaces"));
   assertEquals(
       Arrays.asList(nodeId), graphdbHelper.queryIndexedNodes(indexName, key, "*spaces*"));
   assertTrue(graphdbHelper.getIndexedNodes(indexName, key, "nohit").isEmpty());
 }