если объект найден по реквизиту (колонка в FTS), в выдаче показывается только совпавший реквизит с типом значения — в том же формате дерева

This commit is contained in:
mihailkudravcev
2026-07-17 16:56:15 +03:00
parent 404659a545
commit 06e13395f8
6 changed files with 239 additions and 53 deletions
+18 -23
View File
@@ -54,9 +54,11 @@ from index1c.search import ( # noqa: E402
search_objects,
)
from index1c.object_view import ( # noqa: E402
enrich_matched_fields,
find_structure_matches,
format_object_tree,
load_object_structure,
load_object_structure_for_row,
)
@@ -91,7 +93,21 @@ def cmd_search(args: argparse.Namespace) -> int:
for r in rows:
syn = f"{r['synonym']}" if r.get("synonym") else ""
print(f"- [{r['config']}] `{r['full_name']}`{syn}")
if r.get("snip"):
matched = list(r.get("matched_fields") or [])
if r.get("match_kind") == "field" and matched:
obj = load_object_structure_for_row(conn, r)
enrich_matched_fields(obj, matched)
block = format_object_tree(
obj,
clear=True,
matched_fields=matched,
match_kind="field",
omit_header=True,
)
for line in block.splitlines():
if line:
print(f" {line}")
elif r.get("snip"):
print(f" {r['snip']}")
return 0
finally:
@@ -283,29 +299,8 @@ def cmd_object(args: argparse.Namespace) -> int:
if i:
print()
obj = load_object_structure(m)
# подтянуть FillChecking/типы из свежего XML в matched_fields
matched = list(m.get("matched_fields") or [])
if matched and obj.get("fields"):
by_f = {
(
f.get("tabular_section") or "",
f.get("name") or "",
f.get("kind") or "",
): f
for f in obj["fields"]
}
for mf in matched:
key = (
mf.get("tabular_section") or "",
mf.get("name") or "",
mf.get("kind") or "",
)
src = by_f.get(key)
if src:
mf["fill_checking"] = src.get("fill_checking") or ""
mf["types"] = src.get("types") or mf.get("types")
mf["synonym"] = src.get("synonym") or mf.get("synonym")
mf["refs"] = src.get("refs") or mf.get("refs")
enrich_matched_fields(obj, matched)
# точное совпадение объекта (score 0) → clear без дерева;
# иначе при найденных реквизитах — clear только по ним
kind = m.get("match_kind") or "object"