Merge pull request #1322 from danielaskdd/main
Browse files
lightrag/api/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1 |
-
__api_version__ = "
|
|
|
1 |
+
__api_version__ = "0141"
|
lightrag/api/webui/assets/{index-1f7er6cN.js → index-DVJJypi_.js}
RENAMED
Binary files a/lightrag/api/webui/assets/index-1f7er6cN.js and b/lightrag/api/webui/assets/index-DVJJypi_.js differ
|
|
lightrag/api/webui/index.html
CHANGED
Binary files a/lightrag/api/webui/index.html and b/lightrag/api/webui/index.html differ
|
|
lightrag_webui/src/components/graph/GraphLabels.tsx
CHANGED
@@ -46,8 +46,30 @@ const GraphLabels = () => {
|
|
46 |
|
47 |
let result: string[] = labels
|
48 |
if (query) {
|
49 |
-
// Search labels
|
50 |
result = searchEngine.search(query).map((r: { id: number }) => labels[r.id])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
return result.length <= labelListLimit
|
|
|
46 |
|
47 |
let result: string[] = labels
|
48 |
if (query) {
|
49 |
+
// Search labels using MiniSearch
|
50 |
result = searchEngine.search(query).map((r: { id: number }) => labels[r.id])
|
51 |
+
|
52 |
+
// Add middle-content matching if results are few
|
53 |
+
// This enables matching content in the middle of text, not just from the beginning
|
54 |
+
if (result.length < 5) {
|
55 |
+
// Get already matched labels to avoid duplicates
|
56 |
+
const matchedLabels = new Set(result)
|
57 |
+
|
58 |
+
// Perform middle-content matching on all labels
|
59 |
+
const middleMatchResults = labels.filter(label => {
|
60 |
+
// Skip already matched labels
|
61 |
+
if (matchedLabels.has(label)) return false
|
62 |
+
|
63 |
+
// Match if label contains query string but doesn't start with it
|
64 |
+
return label &&
|
65 |
+
typeof label === 'string' &&
|
66 |
+
!label.toLowerCase().startsWith(query.toLowerCase()) &&
|
67 |
+
label.toLowerCase().includes(query.toLowerCase())
|
68 |
+
})
|
69 |
+
|
70 |
+
// Merge results
|
71 |
+
result = [...result, ...middleMatchResults]
|
72 |
+
}
|
73 |
}
|
74 |
|
75 |
return result.length <= labelListLimit
|
lightrag_webui/src/components/graph/GraphSearch.tsx
CHANGED
@@ -123,13 +123,42 @@ export const GraphSearchInput = ({
|
|
123 |
}
|
124 |
|
125 |
// If has query, search nodes and verify they still exist
|
126 |
-
|
127 |
.filter((r: { id: string }) => graph.hasNode(r.id))
|
128 |
.map((r: { id: string }) => ({
|
129 |
id: r.id,
|
130 |
type: 'nodes'
|
131 |
}))
|
132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
// prettier-ignore
|
134 |
return result.length <= searchResultLimit
|
135 |
? result
|
|
|
123 |
}
|
124 |
|
125 |
// If has query, search nodes and verify they still exist
|
126 |
+
let result: OptionItem[] = searchEngine.search(query)
|
127 |
.filter((r: { id: string }) => graph.hasNode(r.id))
|
128 |
.map((r: { id: string }) => ({
|
129 |
id: r.id,
|
130 |
type: 'nodes'
|
131 |
}))
|
132 |
|
133 |
+
// Add middle-content matching if results are few
|
134 |
+
// This enables matching content in the middle of text, not just from the beginning
|
135 |
+
if (result.length < 5) {
|
136 |
+
// Get already matched IDs to avoid duplicates
|
137 |
+
const matchedIds = new Set(result.map(item => item.id))
|
138 |
+
|
139 |
+
// Perform middle-content matching on all nodes
|
140 |
+
const middleMatchResults = graph.nodes()
|
141 |
+
.filter(id => {
|
142 |
+
// Skip already matched nodes
|
143 |
+
if (matchedIds.has(id)) return false
|
144 |
+
|
145 |
+
// Get node label
|
146 |
+
const label = graph.getNodeAttribute(id, 'label')
|
147 |
+
// Match if label contains query string but doesn't start with it
|
148 |
+
return label &&
|
149 |
+
typeof label === 'string' &&
|
150 |
+
!label.toLowerCase().startsWith(query.toLowerCase()) &&
|
151 |
+
label.toLowerCase().includes(query.toLowerCase())
|
152 |
+
})
|
153 |
+
.map(id => ({
|
154 |
+
id,
|
155 |
+
type: 'nodes' as const
|
156 |
+
}))
|
157 |
+
|
158 |
+
// Merge results
|
159 |
+
result = [...result, ...middleMatchResults]
|
160 |
+
}
|
161 |
+
|
162 |
// prettier-ignore
|
163 |
return result.length <= searchResultLimit
|
164 |
? result
|