KnowledgeGraph.search()

Search nodes by name or content (case-insensitive word matching).

Usage

Source

KnowledgeGraph.search(
    query,
    *,
    node_type=None,
    layer=None,
    limit=20,
)

Tokenises the query into words and matches nodes where any word appears in the name or content. Results are ranked by the number of matching words, with name matches weighted higher than content matches.

Parameters

query: str

Text to search for in node names and content.

node_type: NodeType | None = None

Optional filter by node type.

layer: GraphLayer | None = None

Optional filter by graph layer.

limit: int = 20
Maximum results to return.

Returns

list[Node]
Matching nodes, ranked by relevance (word-match count).

Examples

results = kg.search("python", node_type=tb.NodeType.ENTITY)