diff --git a/lightrag_webui/src/components/graph/GraphSearch.tsx b/lightrag_webui/src/components/graph/GraphSearch.tsx index 943b932d..05a26c68 100644 --- a/lightrag_webui/src/components/graph/GraphSearch.tsx +++ b/lightrag_webui/src/components/graph/GraphSearch.tsx @@ -85,7 +85,18 @@ export const GraphSearchInput = ({ const loadOptions = useCallback( async (query?: string): Promise => { if (onFocus) onFocus(null) - if (!query || !searchEngine) return [] + if (!graph || !searchEngine) return [] + + // If no query, return first searchResultLimit nodes + if (!query) { + const nodeIds = graph.nodes().slice(0, searchResultLimit) + return nodeIds.map(id => ({ + id, + type: 'nodes' + })) + } + + // If has query, search nodes const result: OptionItem[] = searchEngine.search(query).map((r: { id: string }) => ({ id: r.id, type: 'nodes' @@ -103,7 +114,7 @@ export const GraphSearchInput = ({ } ] }, - [searchEngine, onFocus, t] + [graph, searchEngine, onFocus, t] ) return ( diff --git a/lightrag_webui/src/components/ui/AsyncSearch.tsx b/lightrag_webui/src/components/ui/AsyncSearch.tsx index a9b3a6ce..339c0313 100644 --- a/lightrag_webui/src/components/ui/AsyncSearch.tsx +++ b/lightrag_webui/src/components/ui/AsyncSearch.tsx @@ -193,7 +193,7 @@ export function AsyncSearch({ )} -