org.neo4j.graphdb.index.IndexManager Java Examples
The following examples show how to use
org.neo4j.graphdb.index.IndexManager.
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: MoveIndicesToIsLatestVertexMigration.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
@Override public void execute(TinkerPopGraphManager graphWrapper) throws IOException { GraphDatabaseService service = graphWrapper.getGraphDatabase(); IndexManager indexManager = service.index(); try (Transaction tx = graphWrapper.getGraph().tx()) { clearIndices(indexManager); tx.commit(); } try (Transaction tx = graphWrapper.getGraph().tx()) { if (!tx.isOpen()) { tx.open(); } constructIndices(indexManager); fillVertexIndices(graphWrapper, indexManager); fillEdgeIndex(service, indexManager); tx.commit(); } }
Example #2
Source File: MoveIndicesToIsLatestVertexMigration.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
private void fillVertexIndices(TinkerPopGraphManager graphWrapper, IndexManager indexManager) { ObjectMapper mapper = new ObjectMapper(); GraphTraversalSource traversalSource = graphWrapper.getGraph().traversal(); Collection wwpersonCollection = vres.getCollection("wwpersons").orElse(null); graphWrapper.getGraphDatabase().getAllNodes().stream() .filter(node -> node.hasProperty("tim_id")) .filter(this::isLatest) .forEach(node -> { updateIdIndex(indexManager, node); if (!isDeleted(node)) { updateQuicksearchIndex(vres, indexManager, mapper, node, wwpersonCollection, traversalSource); } }); }
Example #3
Source File: MoveIndicesToIsLatestVertexMigration.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
private void updateQuicksearchIndex(Vres vres, IndexManager indexManager, ObjectMapper mapper, Node node, Collection wwpersonCollection, GraphTraversalSource traversalSource) { for (String type : getEntityTypes(node, mapper)) { if (!type.equals("relationtype")) { Optional<Collection> collection = vres.getCollectionForType(type); long id = node.getId(); if (collection.isPresent()) { String displayName; if (type.equals("wwdocument")) { displayName = getWwDocumentsQuickSearchValue(collection.get(), wwpersonCollection, id, traversalSource ); } else { displayName = getGenericQuickSearchValue(collection.get(), id, traversalSource); } indexManager.forNodes(collection.get().getCollectionName()).add(node, "quickSearch", displayName); } else { LOG.error("Could not find collection for " + type + " at vertex " + id); } } } }
Example #4
Source File: MoveIndicesToIsLatestVertexMigration.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
private void constructIndices(IndexManager indexManager) { Map<String, String> indexConfig = MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type", "fulltext"); //construct all quicksearchIndices vres.getVres().values().stream() .flatMap(vre -> vre.getCollections().values().stream()) .forEach((collection) -> { indexManager.forNodes(collection.getCollectionName(), indexConfig); }); //construct id index indexManager.forNodes("idIndex"); //construct edge index indexManager.forNodes("edgeIdIndex"); }
Example #5
Source File: MoveIndicesToIsLatestVertexMigration.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
private void clearIndices(IndexManager indexManager) { //delete all quicksearchIndices vres.getVres().values().stream() .flatMap(vre -> vre.getCollections().values().stream()) .forEach((collection) -> { deleteIndex(indexManager, collection.getCollectionName()); }); //delete id index deleteIndex(indexManager, "idIndex"); //delete edge index deleteIndex(indexManager, "edgeIdIndex"); }
Example #6
Source File: MoveIndicesToIsLatestVertexMigration.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
private void fillEdgeIndex(GraphDatabaseService service, IndexManager indexManager) { service.getAllRelationships().stream() .filter(e -> e.hasProperty("tim_id")) .filter(this::isLatest) .forEach(edge -> { indexManager.forRelationships("edgeIdIndex").add(edge, "tim_id", edge.getProperty("tim_id")); }); }
Example #7
Source File: Neo4jIndexHandler.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
private Index<Node> getQuickSearchIndex(Collection collection) { // Add the config below, to make sure the index is case insensitive. Map<String, String> indexConfig = MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type", "fulltext"); return indexManager().forNodes(getQuicksearchIndexName(collection), indexConfig); }
Example #8
Source File: Neo4jIndexHandler.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
private IndexManager indexManager() { return graphDatabase().index(); }
Example #9
Source File: MoveIndicesToIsLatestVertexMigration.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
private void updateIdIndex(IndexManager indexManager, Node node) { indexManager.forNodes("idIndex").add(node, "tim_id", node.getProperty("tim_id")); }
Example #10
Source File: MoveIndicesToIsLatestVertexMigration.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
private void deleteIndex(IndexManager indexManager, String name) { if (indexManager.existsForNodes(name)) { indexManager.forNodes(name).delete(); } }
Example #11
Source File: FulltextIndex.java From ongdb-lab-apoc with Apache License 2.0 | 2 votes |
/** * @param * @return * @Description: TODO(索引预配置) */ private Index<Node> getNodeIndex(String name, Map<String, String> config) { IndexManager mgr = db.index(); return config == null ? mgr.forNodes(name) : mgr.forNodes(name, config); }