Skip to content

Commit 9417e28

Browse files
authored
refactor: rename document_indexes to document_index and update related indices (#975)
1 parent ce378f1 commit 9417e28

5 files changed

Lines changed: 70 additions & 50 deletions

File tree

aperag/db/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ class LightRAGLLMCacheModel(Base):
702702
class DocumentIndex(Base):
703703
"""Document index - combines spec and status into single table"""
704704

705-
__tablename__ = "document_indexes"
705+
__tablename__ = "document_index"
706706
__table_args__ = (UniqueConstraint("document_id", "index_type", name="uq_document_index"),)
707707

708708
id = Column(Integer, primary_key=True, index=True)

aperag/migration/versions/20250617113447-dcc0b6c56552.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def upgrade() -> None:
122122
op.create_index(op.f('ix_document_gmt_deleted'), 'document', ['gmt_deleted'], unique=False)
123123
op.create_index(op.f('ix_document_status'), 'document', ['status'], unique=False)
124124
op.create_index(op.f('ix_document_user'), 'document', ['user'], unique=False)
125-
op.create_table('document_indexes',
125+
op.create_table('document_index',
126126
sa.Column('id', sa.Integer(), nullable=False),
127127
sa.Column('document_id', sa.String(length=24), nullable=False),
128128
sa.Column('index_type', sa.Enum('vector', 'fulltext', 'graph', name='documentindextype'), nullable=False),
@@ -139,11 +139,11 @@ def upgrade() -> None:
139139
sa.PrimaryKeyConstraint('id'),
140140
sa.UniqueConstraint('document_id', 'index_type', name='uq_document_index')
141141
)
142-
op.create_index(op.f('ix_document_indexes_actual_state'), 'document_indexes', ['actual_state'], unique=False)
143-
op.create_index(op.f('ix_document_indexes_desired_state'), 'document_indexes', ['desired_state'], unique=False)
144-
op.create_index(op.f('ix_document_indexes_document_id'), 'document_indexes', ['document_id'], unique=False)
145-
op.create_index(op.f('ix_document_indexes_id'), 'document_indexes', ['id'], unique=False)
146-
op.create_index(op.f('ix_document_indexes_index_type'), 'document_indexes', ['index_type'], unique=False)
142+
op.create_index(op.f('ix_document_index_actual_state'), 'document_index', ['actual_state'], unique=False)
143+
op.create_index(op.f('ix_document_index_desired_state'), 'document_index', ['desired_state'], unique=False)
144+
op.create_index(op.f('ix_document_index_document_id'), 'document_index', ['document_id'], unique=False)
145+
op.create_index(op.f('ix_document_index_id'), 'document_index', ['id'], unique=False)
146+
op.create_index(op.f('ix_document_index_index_type'), 'document_index', ['index_type'], unique=False)
147147
op.create_table('invitation',
148148
sa.Column('id', sa.String(length=24), nullable=False),
149149
sa.Column('email', sa.String(length=254), nullable=False),
@@ -367,12 +367,12 @@ def downgrade() -> None:
367367
op.drop_table('lightrag_doc_full')
368368
op.drop_table('lightrag_doc_chunks')
369369
op.drop_table('invitation')
370-
op.drop_index(op.f('ix_document_indexes_index_type'), table_name='document_indexes')
371-
op.drop_index(op.f('ix_document_indexes_id'), table_name='document_indexes')
372-
op.drop_index(op.f('ix_document_indexes_document_id'), table_name='document_indexes')
373-
op.drop_index(op.f('ix_document_indexes_desired_state'), table_name='document_indexes')
374-
op.drop_index(op.f('ix_document_indexes_actual_state'), table_name='document_indexes')
375-
op.drop_table('document_indexes')
370+
op.drop_index(op.f('ix_document_index_index_type'), table_name='document_index')
371+
op.drop_index(op.f('ix_document_index_id'), table_name='document_index')
372+
op.drop_index(op.f('ix_document_index_document_id'), table_name='document_index')
373+
op.drop_index(op.f('ix_document_index_desired_state'), table_name='document_index')
374+
op.drop_index(op.f('ix_document_index_actual_state'), table_name='document_index')
375+
op.drop_table('document_index')
376376
op.drop_index(op.f('ix_document_user'), table_name='document')
377377
op.drop_index(op.f('ix_document_status'), table_name='document')
378378
op.drop_index(op.f('ix_document_gmt_deleted'), table_name='document')

frontend/src/locales/en-US.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ export default {
227227
'document.index.status.COMPLETE': 'Completed',
228228
'document.index.status.FAILED': 'Failed',
229229
'document.index.status.SKIPPED': 'Skipped',
230+
'document.index.type.vector': 'Vector Index',
231+
'document.index.type.fulltext': 'Fulltext Index',
232+
'document.index.type.graph': 'Graph Index',
230233

231234
flow: '---------------',
232235
'flow.name': 'Workflow',

frontend/src/locales/zh-CN.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ export default {
225225
'document.index.status.COMPLETE': '已完成',
226226
'document.index.status.FAILED': '失败',
227227
'document.index.status.SKIPPED': '已跳过',
228+
'document.index.type.vector': '向量索引',
229+
'document.index.type.fulltext': '全文索引',
230+
'document.index.type.graph': '图索引',
228231

229232
flow: '---------------',
230233
'flow.name': '任务流',

frontend/src/pages/collections/$collectionId/documents.tsx

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
Dropdown,
3030
Input,
3131
Modal,
32-
Popover,
3332
Space,
3433
Table,
3534
TableProps,
@@ -93,23 +92,54 @@ export default () => {
9392
graphStatus?: DocumentGraphIndexStatusEnum,
9493
) => {
9594
const indexTypes = [
96-
{ name: 'vector_search', status: vectorStatus },
97-
{ name: 'fulltext_search', status: fulltextStatus },
98-
{ name: 'graph_search', status: graphStatus },
95+
{ nameKey: 'document.index.type.vector', status: vectorStatus },
96+
{ nameKey: 'document.index.type.fulltext', status: fulltextStatus },
97+
{ nameKey: 'document.index.type.graph', status: graphStatus },
9998
];
10099
return (
101100
<Space direction="vertical" size="small">
102-
{indexTypes.map(({ name, status }, index) => (
103-
<Badge
104-
key={index}
105-
status={UI_INDEX_STATUS[status as keyof typeof UI_INDEX_STATUS]}
106-
text={
107-
<span style={{ fontSize: '0.9em' }}>
108-
{formatMessage({ id: `searchTest.type.${name}` })}:&nbsp;
109-
{formatMessage({ id: `document.index.status.${status}` })}
110-
</span>
111-
}
112-
/>
101+
{indexTypes.map(({ nameKey, status }, index) => (
102+
<div
103+
key={index}
104+
style={{
105+
fontSize: '12px',
106+
lineHeight: '18px',
107+
display: 'flex',
108+
alignItems: 'center',
109+
whiteSpace: 'nowrap'
110+
}}
111+
>
112+
<span
113+
style={{
114+
color: '#666',
115+
width: '100px',
116+
textAlign: 'right',
117+
display: 'inline-block'
118+
}}
119+
>
120+
{formatMessage({ id: nameKey })}
121+
</span>
122+
<span
123+
style={{
124+
color: '#666',
125+
width: '12px',
126+
textAlign: 'center',
127+
display: 'inline-block'
128+
}}
129+
>
130+
131+
</span>
132+
<div style={{ width: '80px' }}>
133+
<Badge
134+
status={UI_INDEX_STATUS[status as keyof typeof UI_INDEX_STATUS]}
135+
text={
136+
<span style={{ display: 'inline-block', width: '70px' }}>
137+
{formatMessage({ id: `document.index.status.${status}` })}
138+
</span>
139+
}
140+
/>
141+
</div>
142+
</div>
113143
))}
114144
</Space>
115145
);
@@ -149,29 +179,13 @@ export default () => {
149179
{
150180
title: formatMessage({ id: 'document.status' }),
151181
dataIndex: 'status',
152-
width: 120,
182+
width: 190,
183+
align: 'center',
153184
render: (value, record) => {
154-
return (
155-
<Popover
156-
content={renderIndexStatus(
157-
record.vector_index_status,
158-
record.fulltext_index_status,
159-
record.graph_index_status,
160-
)}
161-
styles={{
162-
root: {
163-
minWidth: 200,
164-
},
165-
}}
166-
>
167-
<Badge
168-
status={
169-
record.status ? UI_DOCUMENT_STATUS[record.status] : 'default'
170-
}
171-
text={formatMessage({ id: `document.status.${value}` })}
172-
style={{ cursor: 'pointer' }}
173-
/>
174-
</Popover>
185+
return renderIndexStatus(
186+
record.vector_index_status,
187+
record.fulltext_index_status,
188+
record.graph_index_status,
175189
);
176190
},
177191
},

0 commit comments

Comments
 (0)