Java Code Examples for org.neo4j.graphdb.index.Index#remove()

The following examples show how to use org.neo4j.graphdb.index.Index#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FulltextIndex.java    From ongdb-lab-apoc with Apache License 2.0 5 votes vote down vote up
private <T extends PropertyContainer> void indexEntityWithMap(T pc, Map<String, Object> document, Index<T> index) {
    index.remove(pc);
    document.forEach((key, value) -> {
        index.remove(pc, key);
        index.add(pc, key, value);
        System.out.println("Node:" + pc + "," + key + ":" + value);
    });
}
 
Example 2
Source File: FulltextIndex.java    From ongdb-lab-apoc with Apache License 2.0 5 votes vote down vote up
/**
 * @param
 * @return
 * @Description: TODO(构建索引并返回MESSAGE - 支持自动更新)
 */
private String chineseFulltextAutoIndex(String indexName, String labelName, List<String> propKeys, Map<String, String> options) {

    Label label = Label.label(labelName);

    // 按照标签找到该标签下的所有节点
    ResourceIterator<Node> nodes = db.findNodes(label);

    // 合并用户配置
    FULL_INDEX_CONFIG.putAll(options);

    int nodesSize = 0;
    int propertiesSize = 0;
    while (nodes.hasNext()) {
        nodesSize++;
        Node node = nodes.next();
        System.out.println("current nodes:" + node.toString());

        // 每个节点上需要添加索引的属性
        Set<Map.Entry<String, Object>> properties = node.getProperties(propKeys.toArray(new String[0])).entrySet();
        System.out.println("current node properties" + properties);

        // 查询该节点是否已有索引,有的话删除
        if (db.index().existsForNodes(indexName)) {
            Index<Node> oldIndex = db.index().forNodes(indexName);
            System.out.println("current node index" + oldIndex);
            oldIndex.remove(node);
        }

        // 为该节点的每个需要添加索引的属性添加全文索引
        Index<Node> nodeIndex = db.index().forNodes(indexName, FULL_INDEX_CONFIG);
        for (Map.Entry<String, Object> property : properties) {
            propertiesSize++;
            nodeIndex.add(node, property.getKey(), property.getValue());
        }
    }

    String message = "IndexName:" + indexName + ",LabelName:" + labelName + ",NodesSize:" + nodesSize + ",PropertiesSize:" + propertiesSize;
    return message;
}
 
Example 3
Source File: Neo4jIndexHandler.java    From timbuctoo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void removeFromQuickSearchIndex(Collection collection, Vertex vertex) {
  Index<Node> index = getQuickSearchIndex(collection);
  // make sure only this field is removed from the index.
  final Optional<Node> node = vertexToNode(vertex);
  if (node.isPresent()) {
    index.remove(node.get(), QUICK_SEARCH_PROP_NAME);
  }
}