use of org.neo4j.procedure.Description in project neo4j by neo4j.
the class BuiltInProcedures method listIndexes.
@Deprecated(since = "4.2.0", forRemoval = true)
@SystemProcedure
@Description("List all indexes in the database.")
@Procedure(name = "db.indexes", mode = READ, deprecatedBy = "SHOW INDEXES command")
public Stream<IndexResult> listIndexes() {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
TokenRead tokenRead = kernelTransaction.tokenRead();
IndexingService indexingService = resolver.resolveDependency(IndexingService.class);
SchemaReadCore schemaRead = kernelTransaction.schemaRead().snapshot();
List<IndexDescriptor> indexes = asList(schemaRead.indexesGetAll());
List<IndexResult> result = new ArrayList<>();
for (IndexDescriptor index : indexes) {
IndexResult indexResult;
indexResult = asIndexResult(tokenRead, schemaRead, index);
result.add(indexResult);
}
result.sort(Comparator.comparing(r -> r.name));
return result.stream();
}
use of org.neo4j.procedure.Description in project neo4j by neo4j.
the class FulltextProcedures method createRelationshipFulltextIndex.
@Deprecated(since = "4.3.0", forRemoval = true)
@Description("Create a relationship full-text index for the given relationship types and properties. " + "The optional 'config' map parameter can be used to supply settings to the index. " + "Supported settings are '" + PROCEDURE_ANALYZER + "', for specifying what analyzer to use " + "when indexing and querying. Use the `db.index.fulltext.listAvailableAnalyzers` procedure to see what options are available. " + "And '" + PROCEDURE_EVENTUALLY_CONSISTENT + "' which can be set to 'true' to make this index eventually consistent, " + "such that updates from committing transactions are applied in a background thread.")
@Procedure(name = "db.index.fulltext.createRelationshipIndex", mode = SCHEMA, deprecatedBy = "CREATE FULLTEXT INDEX command")
public void createRelationshipFulltextIndex(@Name("indexName") String name, @Name("relationshipTypes") List<String> relTypes, @Name("properties") List<String> properties, @Name(value = "config", defaultValue = "{}") Map<String, String> config) {
RelationshipType[] types = relTypes.stream().map(RelationshipType::withName).toArray(RelationshipType[]::new);
IndexCreator indexCreator = transaction.schema().indexFor(types);
createIndex(indexCreator, name, properties, config);
}
use of org.neo4j.procedure.Description in project neo4j by neo4j.
the class FulltextProcedures method createNodeFulltextIndex.
@Deprecated(since = "4.3.0", forRemoval = true)
@Description("Create a node full-text index for the given labels and properties. " + "The optional 'config' map parameter can be used to supply settings to the index. " + "Supported settings are '" + PROCEDURE_ANALYZER + "', for specifying what analyzer to use " + "when indexing and querying. Use the `db.index.fulltext.listAvailableAnalyzers` procedure to see what options are available. " + "And '" + PROCEDURE_EVENTUALLY_CONSISTENT + "' which can be set to 'true' to make this index eventually consistent, " + "such that updates from committing transactions are applied in a background thread.")
@Procedure(name = "db.index.fulltext.createNodeIndex", mode = SCHEMA, deprecatedBy = "CREATE FULLTEXT INDEX command")
public void createNodeFulltextIndex(@Name("indexName") String name, @Name("labels") List<String> labelNames, @Name("properties") List<String> properties, @Name(value = "config", defaultValue = "{}") Map<String, String> config) {
Label[] labels = labelNames.stream().map(Label::label).toArray(Label[]::new);
IndexCreator indexCreator = transaction.schema().indexFor(labels);
createIndex(indexCreator, name, properties, config);
}
use of org.neo4j.procedure.Description in project neo4j by neo4j.
the class FulltextProcedures method queryFulltextForRelationships.
@SystemProcedure
@Description("Query the given full-text index. Returns the matching relationships, and their Lucene query score, ordered by score. " + "Valid keys for the options map are: 'skip' to skip the top N results; 'limit' to limit the number of results returned.")
@Procedure(name = "db.index.fulltext.queryRelationships", mode = READ)
public Stream<RelationshipOutput> queryFulltextForRelationships(@Name("indexName") String name, @Name("queryString") String query, @Name(value = "options", defaultValue = "{}") Map<String, Object> options) throws Exception {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
IndexDescriptor indexReference = getValidIndex(name);
awaitOnline(indexReference);
EntityType entityType = indexReference.schema().entityType();
if (entityType != RELATIONSHIP) {
throw new IllegalArgumentException("The '" + name + "' index (" + indexReference + ") is an index on " + entityType + ", so it cannot be queried for relationships.");
}
RelationshipValueIndexCursor cursor = tx.cursors().allocateRelationshipValueIndexCursor(tx.cursorContext(), tx.memoryTracker());
IndexReadSession indexReadSession = tx.dataRead().indexReadSession(indexReference);
IndexQueryConstraints constraints = queryConstraints(options);
tx.dataRead().relationshipIndexSeek(indexReadSession, cursor, constraints, PropertyIndexQuery.fulltextSearch(query));
Spliterator<RelationshipOutput> spliterator = new SpliteratorAdaptor<>() {
@Override
public boolean tryAdvance(Consumer<? super RelationshipOutput> action) {
while (cursor.next()) {
long relationshipReference = cursor.relationshipReference();
float score = cursor.score();
RelationshipOutput relationshipOutput = RelationshipOutput.forExistingEntityOrNull(transaction, relationshipReference, score);
if (relationshipOutput != null) {
action.accept(relationshipOutput);
return true;
}
}
cursor.close();
return false;
}
};
return StreamSupport.stream(spliterator, false).onClose(cursor::close);
}
use of org.neo4j.procedure.Description in project neo4j by neo4j.
the class AuthProcedures method listUsers.
@SystemProcedure
@Deprecated
@Description("List all native users.")
@Procedure(name = "dbms.security.listUsers", mode = READ, deprecatedBy = "Administration command: SHOW USERS")
public Stream<UserResult> listUsers() throws ProcedureException {
var query = "SHOW USERS";
List<UserResult> result = new ArrayList<>();
try {
Result execute = transaction.execute(query);
execute.accept(row -> {
var username = row.getString("user");
var changeRequired = row.getBoolean("passwordChangeRequired");
result.add(new UserResult(username, changeRequired));
return true;
});
} catch (Exception e) {
translateException(e, "dbms.security.listUsers");
}
if (result.isEmpty()) {
return showCurrentUser();
}
return result.stream();
}
Aggregations