onesearch-cli 0.13.2__tar.gz → 0.14.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/PKG-INFO +1 -1
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/__init__.py +1 -1
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/api.py +4 -2
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/commands/source.py +6 -3
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/pyproject.toml +1 -1
- onesearch_cli-0.14.0/tests/test_reindex_full.py +42 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/.gitignore +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/README.md +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/banner.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/commands/__init__.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/commands/auth.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/commands/config.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/commands/search.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/commands/status.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/config.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/context.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/onesearch/main.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/tests/test_api.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/tests/test_auth_commands.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/tests/test_banner.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/tests/test_config.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/tests/test_integration_auth.py +0 -0
- {onesearch_cli-0.13.2 → onesearch_cli-0.14.0}/tests/test_main.py +0 -0
|
@@ -203,16 +203,18 @@ class OneSearchAPI:
|
|
|
203
203
|
"""Delete a source."""
|
|
204
204
|
self._request("DELETE", f"/api/sources/{source_id}")
|
|
205
205
|
|
|
206
|
-
def reindex_source(self, source_id: str) -> dict:
|
|
206
|
+
def reindex_source(self, source_id: str, full: bool = False) -> dict:
|
|
207
207
|
"""Trigger reindex for a source.
|
|
208
208
|
|
|
209
209
|
Args:
|
|
210
210
|
source_id: Source ID.
|
|
211
|
+
full: If true, clear metadata and rebuild every file from scratch.
|
|
211
212
|
|
|
212
213
|
Returns:
|
|
213
214
|
Reindex result with statistics.
|
|
214
215
|
"""
|
|
215
|
-
|
|
216
|
+
suffix = "?full=true" if full else ""
|
|
217
|
+
return self._request("POST", f"/api/sources/{source_id}/reindex{suffix}")
|
|
216
218
|
|
|
217
219
|
# Search endpoints
|
|
218
220
|
def search(
|
|
@@ -196,8 +196,9 @@ def source_delete(ctx: Context, source_id: str, yes: bool):
|
|
|
196
196
|
|
|
197
197
|
@source.command("reindex")
|
|
198
198
|
@click.argument("source_id")
|
|
199
|
+
@click.option("--full", is_flag=True, help="Clear indexed metadata and rebuild every file from scratch.")
|
|
199
200
|
@pass_context
|
|
200
|
-
def source_reindex(ctx: Context, source_id: str):
|
|
201
|
+
def source_reindex(ctx: Context, source_id: str, full: bool):
|
|
201
202
|
"""Trigger reindex for a source.
|
|
202
203
|
|
|
203
204
|
\b
|
|
@@ -205,14 +206,16 @@ def source_reindex(ctx: Context, source_id: str):
|
|
|
205
206
|
SOURCE_ID The source ID to reindex
|
|
206
207
|
|
|
207
208
|
This will scan the source path and index all matching files.
|
|
209
|
+
Use --full after managed Meilisearch migrations or to repair index drift.
|
|
208
210
|
"""
|
|
209
211
|
api = ctx.get_api()
|
|
210
212
|
out = ctx.get_console()
|
|
211
213
|
try:
|
|
212
214
|
s = api.get_source(source_id)
|
|
213
|
-
|
|
215
|
+
action = "Full reindexing" if full else "Reindexing"
|
|
216
|
+
out.print(f"[dim]{action} source [cyan]{s['name']}[/cyan]...[/dim]")
|
|
214
217
|
|
|
215
|
-
result = api.reindex_source(source_id)
|
|
218
|
+
result = api.reindex_source(source_id, full=full)
|
|
216
219
|
|
|
217
220
|
# Backend returns: {"message": ..., "stats": {...}}
|
|
218
221
|
stats = result.get("stats", {})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from click.testing import CliRunner
|
|
2
|
+
|
|
3
|
+
from onesearch.context import Context
|
|
4
|
+
from onesearch.main import cli
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_api_reindex_source_can_request_full_rebuild():
|
|
8
|
+
from onesearch.api import OneSearchAPI
|
|
9
|
+
|
|
10
|
+
calls = []
|
|
11
|
+
api = OneSearchAPI(base_url="http://localhost:8000", token="secret")
|
|
12
|
+
|
|
13
|
+
def fake_request(method, endpoint, **kwargs):
|
|
14
|
+
calls.append((method, endpoint, kwargs))
|
|
15
|
+
return {"stats": {}}
|
|
16
|
+
|
|
17
|
+
api._request = fake_request
|
|
18
|
+
|
|
19
|
+
api.reindex_source("docs", full=True)
|
|
20
|
+
|
|
21
|
+
assert calls == [("POST", "/api/sources/docs/reindex?full=true", {})]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_source_reindex_full_flag_calls_full_reindex(monkeypatch):
|
|
25
|
+
calls = []
|
|
26
|
+
|
|
27
|
+
class FakeAPI:
|
|
28
|
+
def get_source(self, source_id):
|
|
29
|
+
return {"id": source_id, "name": "Docs", "root_path": "/data/docs"}
|
|
30
|
+
|
|
31
|
+
def reindex_source(self, source_id, full=False):
|
|
32
|
+
calls.append((source_id, full))
|
|
33
|
+
return {"stats": {"total_scanned": 1, "successful": 1}}
|
|
34
|
+
|
|
35
|
+
monkeypatch.setattr(Context, "get_api", lambda self: FakeAPI())
|
|
36
|
+
|
|
37
|
+
runner = CliRunner()
|
|
38
|
+
result = runner.invoke(cli, ["source", "reindex", "docs", "--full"], obj=Context())
|
|
39
|
+
|
|
40
|
+
assert result.exit_code == 0
|
|
41
|
+
assert calls == [("docs", True)]
|
|
42
|
+
assert "Full reindexing source" in result.output
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|