Схема индексов OpenSearch — Grace CRM Assistant
Версия: 1.2.0 Дата: 422 маяиюля 2026 (актуализация по проду)
Источник: OpenSearch http://localhost:9200 файл 01_opensearch_schema.md
Всего индексов: 1531
1. Назначение слоя OpenSearch
OpenSearch является поисковым и аналитическим слоем системы. Данные поступают из Grace CRM через Sync Agent и хранятся в виде денормализованных витрин, оптимизированных под сценарии работы AI-агентов.
Ключевые принципы:
-
OpenSearch не является источником истины -- им остаётся Grace CRM (MySQL)
-
Все изменения идут по цепочке: Grace CRM -> Sync Agent -> OpenSearch
-
При расхождении данных MySQL приоритетен
-
company_id = 1соответствует компании I-Tech
2. Индексы контура Sales AI
2.1 itech_projects -- Сделки (Opportunities)
Центральный индекс воронки продаж. Используется Quality Agent и Recommendation Agent.
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
number |
keyword | Номер сделки |
name |
text + .keyword | ru_standard |
account_id |
integer | -> itech_accounts.id |
account_name |
text + .keyword | ru_standard |
manager_id |
integer | |
manager_name |
text + .keyword | standard |
engineer_user_id |
integer | |
engineer_name |
text + .keyword | standard |
property_id |
integer | -> itech_properties.id |
property_name |
text + .keyword | ru_standard |
project_status_id |
integer | |
project_status |
text + .keyword | standard |
probability_new |
keyword | Вероятность (категория) |
probability_percent |
integer | Вероятность, % |
amount |
double | Сумма сделки |
type_of_calculation |
keyword | Тип тендера |
forecast_date |
date | Прогнозная дата закрытия |
refusal_reason |
text | Причина отказа, ru_standard |
created_at |
date | |
created_year |
integer |
Правила фильтрации для агентов:
-
Активные проекты: исключить статусы «Отказ покупателя», «Покупатель вышел из тендера», «Отказ от участия»
-
Пробел в данных:
forecast_date IS NULLилиprobability_new IS NULL
2.2 itech_accounts -- Контрагенты
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
name |
text + .keyword | ru_standard |
inn |
keyword | ИНН |
reliability |
keyword | red / yellow / green / black / blue |
manager_id |
integer | |
manager_name |
text + .keyword | standard |
assistant_user_id |
integer | |
is_prepayment_only |
boolean | Только предоплата |
order_count |
integer | Кол-во заказов |
project_count |
integer | Кол-во сделок |
revenue_mln |
float | Выручка, млн руб. |
paid_mln |
float | Оплачено, млн руб. |
debt_mln |
float | Долг, млн руб. |
last_order_at |
date | Дата последнего заказа |
sectors |
keyword | Отраслевые сектора |
top_properties |
keyword | Топ объекты |
created_at |
date |
2.3 itech_calculations -- КП / Расчёты
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
project_id |
integer | -> itech_projects.id |
project_name |
text + .keyword | ru_standard |
account_id |
integer | |
account_name |
text + .keyword | ru_standard |
manager_id |
integer | |
manager_name |
text + .keyword | standard |
engineer_user_id |
integer | |
engineer_name |
text + .keyword | standard |
calculation_status_id |
integer | |
calculation_status |
text + .keyword | standard |
amount |
double | Сумма КП |
type |
keyword | Тип расчёта |
quality |
keyword | Точный / Бюджетная оценка |
is_urgent |
boolean | Срочный |
due_date |
date | Срок выполнения |
kp_exposed_at |
date | Дата выставления КП |
completed_at |
date | |
created_at |
date |
2.4 itech_orders -- Заказы (шапки)
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
order_number |
keyword | Номер заказа |
account_id |
integer | |
account_name |
text + .keyword | ru_standard |
manager_id |
integer | |
manager_name |
text + .keyword | standard |
project_id |
integer | -> itech_projects.id |
total_cost |
double | Итоговая стоимость |
general_purchase |
double | Себестоимость |
is_shipped |
boolean | Отгружен |
bill_type |
keyword | Тип счёта |
run_date |
date | Дата запуска в производство |
shipping_date_plan |
date | Плановая дата отгрузки |
shipping_date_fact |
date | Фактическая дата отгрузки |
created_at |
date |
2.5 itech_order_items -- Позиции заказов
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
order_id |
integer | -> itech_orders.id |
order_number |
keyword | |
name |
text + .keyword | standard |
article |
keyword | Артикул |
amount |
double | Сумма с НДС |
amount_wo_vat |
double | Сумма без НДС |
purchase_plan |
double | Плановая себестоимость |
profit_amount |
double | Прибыль |
hours_plan |
double | Плановые часы |
is_shipped |
boolean | |
shipping_date_plan |
date | |
shipping_date_fact |
date | NULL = позиция в backlog |
created_at |
date |
2.6 itech_comments -- Комментарии
| Поле | Тип | Описание |
|---|---|---|
id |
long | PK |
commentable_type |
keyword | Тип объекта (Project / Calculation / ...) |
commentable_id |
integer | ID объекта |
author_id |
integer | |
author_name |
text + .keyword | standard |
project_id |
integer | -> itech_projects.id |
project_name |
text + .keyword | ru_standard |
project_status |
keyword | Статус на момент комментария |
account_name |
text + .keyword | standard |
manager_name |
text + .keyword | standard |
comment |
text + .keyword | Текст, ru_standard |
created_at |
date |
2.7 itech_contacts -- Контактные лица
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
full_name |
text + .keyword | ru_standard |
job_title |
text + .keyword | Должность |
phones |
keyword | Массив телефонов |
emails |
keyword | Массив email |
is_priority |
boolean | |
accounts |
nested | Связанные контрагенты |
└ account_id |
integer | |
└ account_name |
text + .keyword | |
created_at |
date |
⚠️ accounts -- nested-тип. Обязательно использовать nested query при фильтрации.
2.8 itech_properties -- Строительные объекты
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
name |
text + .keyword | ru_standard |
address_full |
text + .keyword | ru_standard |
city |
keyword | |
region |
keyword | |
property_type |
keyword | Тип объекта |
sector |
keyword | Отрасль |
account_count |
integer | Кол-во контрагентов |
project_count |
integer | Кол-во сделок |
top_account |
keyword | Основной контрагент |
created_at |
date |
2.9 itech_expected_payments -- Ожидаемые платежи
| Поле | Тип | Описание |
|---|---|---|
id |
text + .keyword | PK |
order_id |
integer | -> itech_orders.id |
order_number |
keyword | |
exp_payment_status |
keyword | Статус платежа |
pay_amount |
double | Ожидаемая сумма |
paid_amount |
double | Оплаченная сумма |
pay_date |
date | Ожидаемая дата |
paid_date |
date | Фактическая дата |
created_at |
date |
2.10 itech_users -- Пользователи системы
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
full_name |
text + .keyword | ru_standard |
email |
keyword | |
title |
keyword | Должность |
department |
text + .keyword | standard |
roles |
keyword | Массив ролей |
is_active |
boolean | |
created_at |
date |
3. Индексы продуктового каталога
3.1 itech_nomenclatures -- Мастер-каталог
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
name |
text + .keyword | ru_standard |
article |
keyword | Артикул |
brand |
text + .keyword | Бренд |
created_at |
date |
3.2 itech_calc_nomenclatures -- Расчётная номенклатура
| Поле | Тип | Описание |
|---|---|---|
article |
keyword | PK |
name |
text + .keyword | ru_standard |
price |
float | Нормативная цена |
assembly_time |
float | Норма времени сборки, ч |
weight |
float | Масса, кг |
body_type |
keyword | Тип корпуса |
body_width / body_height / body_depth |
integer | Габариты, мм |
body_ip |
integer | Степень защиты IP |
rated_in |
float | Номинальный ток, А |
icu |
float | Ток отключения, кА |
3.3 itech_bom_components -- BOM-спецификации
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
calculation_id |
integer | -> itech_calculations.id |
project_id |
integer | -> itech_projects.id |
article |
keyword | Артикул компонента |
quantity |
double | Количество |
cost |
double | Стоимость |
currency |
keyword | Валюта |
3.4 itech_purchase_items -- Позиции закупок
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
nomenclature_id |
integer | -> itech_nomenclatures.id |
nomenclature_name |
text + .keyword | ru_standard |
article |
keyword | |
quantity |
integer | Запрошено |
received_quantity |
integer | Получено |
desired_delivery_date |
date | |
created_at |
date |
3.5 itech_digital_requests -- ИТ-задачи
| Поле | Тип | Описание |
|---|---|---|
id |
integer | PK |
name |
text + .keyword | ru_standard |
status |
keyword | Статус |
importance |
keyword | Важность |
department_name |
text + .keyword | Отдел-заказчик |
plan_date_end_development |
date | Плановая дата завершения |
fact_date_end_development |
date | Фактическая дата |
created_at |
date |
4. Схема связей между индексами
itech_projects ──── account_id ────► itech_accountsitech_projects ──── property_id ───► itech_propertiesitech_projects ──── manager_id ────► itech_usersitech_calculations ── project_id ──► itech_projectsitech_orders ──────── project_id ──► itech_projectsitech_order_items ─── order_id ────► itech_ordersitech_expected_payments ─ order_id ► itech_ordersitech_comments ──── project_id ────► itech_projectsitech_contacts ──── accounts[] ────► itech_accounts (nested)itech_bom_components ── calculation_id ► itech_calculationsitech_purchase_items ─── nomenclature_id ► itech_nomenclatures
5. Правила использования агентами
| Агент | Индексы | Операции |
|---|---|---|
| Sync Agent | Все 15 | Запись (bulk index) |
| Quality Agent | itech_projects, itech_calculations, itech_accounts |
Чтение, агрегации |
| Recommendation Agent | itech_projects, itech_accounts, itech_comments, itech_calculations, itech_contacts |
Чтение, fulltext |
| Orchestrator | itech_projects, itech_users |
Чтение |
6. Индексы, добавленные после v1.0
Снято с живого OpenSearch (прод, сервер 147) 22 июля 2026. Схемы полей — из фактического _mapping индексов. Служебные поля _sync_source / _synced_at в таблицах опущены.
6.1 Операционный контур — новые itech_* (синк из Grace)
itech_contracts — Договоры с контрагентами (шапки)
Документов: 1 980
account_id
integer
approval_status
keyword
approval_status_id
integer
assistant_name
keyword
assistant_user_id
integer
contact_id
integer
contract_end_date
date
contract_start_date
date
deadline
date
id
integer
manager_name
keyword
manager_user_id
integer
number
keyword
project_id
integer
signing_date
date
status_id
integer
type
keyword
itech_contract_annexes — Приложения/спецификации к договорам
Документов: 2 986
amount
double
approval_status
keyword
contract_id
integer
currency_code
keyword
id
integer
number
keyword
order_number
keyword
project_id
integer
signing_date
date
start_date
date
status_id
integer
type
keyword
itech_calculation_requests — Заявки на расчёт — входящая очередь инженерам
Документов: 22 745
account_id
integer
calculation_complexity
integer
created_at
date
description
text + .keyword
end_desired
date
end_plan
date
engineer_name
keyword
engineer_user_id
integer
estimated_time
float
id
integer
is_priority
integer
is_question
integer
manager_id
integer
manager_name
keyword
probability_percent
float
project_id
integer
project_path
keyword
property_id
integer
start_plan
date
status_id
integer
type_of_calc_id
integer
updated_at
date
itech_calculation_remarks — Замечания к расчётам
Документов: 41
author_name
keyword
author_user_id
integer
calculation_engineer_user_id
integer
calculation_id
integer
created_at
date
engineer_name
keyword
id
integer
project_id
integer
remark
text + .keyword
itech_services_requests — Сервисные заявки (внутренние закупки/услуги)
Документов: 4 503
account_id
integer
approval_status_id
integer
category
text + .keyword
cost
long
created_at
date
department_id
integer
department_name
text + .keyword
executor_name
text + .keyword
expenditure_item_id
integer
id
integer
order_number
keyword
purpose
text + .keyword
recipient_name
text + .keyword
status_id
integer
itech_object_registrations — Регистрации объектов за контрагентом (защита проекта)
Документов: 467
account_id
integer
contact_id
integer
controller_name
keyword
controller_user_id
integer
created_at
date
id
integer
property_id
integer
itech_quality_managers — Снимки коэффициента качества Кк по менеджерам (витрина Quality Agent)
Документов: 41
clean
integer
gap_count
integer
kk
float
manager
keyword
snapshot_date
date
stale_count
long
total
integer
with_gaps
integer
itech_activity_log — Журнал изменений сущностей (аудит воронки)
Документов: 15 868
account_id
integer
account_name
text + .keyword
action
keyword
amount
double
causer_name
text + .keyword
causer_user_id
integer
changed_fields
keyword
changes_text
text
created_at
date
created_year
integer
engineer_name
text + .keyword
engineer_user_id
integer
entity_id
integer
entity_type
keyword
forecast_date
date
id
long
manager_name
text + .keyword
manager_user_id
integer
probability_percent
float
project_id
integer
status_id
integer
status_name
keyword
itech_reminders — Напоминания менеджерам (индекс создан, данных пока нет)
Документов: 0
by_email
boolean
by_grace
boolean
by_telegram
boolean
created_at
date
entity_id
integer
entity_type
keyword
id
integer
is_expired
boolean
manager_id
integer
manager_name
text + .keyword
pre_notifications
keyword
remind_date
date
result
text + .keyword
status
keyword
text
text + .keyword
6.2 Продуктовый каталог — itech_vendor_price_lists
Прайс-листы вендоров по артикулам — крупнейший индекс каталога.
Документов: 658 642
article
keyword
brand_id
keyword
currency
keyword
effective_date
date
family
text + .keyword
name
text
price
double
price_list_id
keyword
source
keyword
unit
keyword
vendor
keyword
6.3 Аналитический слой — витрины *_v1 (в v1.0 отсутствовал)
Считаются у нас (не синк из Grace): модель конверсии сделок (агент Quality) и поиск похожих проектов (агент Recommendation).
deal_conversion_training_v1 — Обучающая выборка модели конверсии сделок (признаки + метка converted)
Документов: 8 648
account_id
keyword
amount
double
comment_avg_gap_days
double
comment_count
double
comment_distinct_authors
double
comment_max_gap_days
double
comment_span_days
double
comments_before_forecast
double
comments_per_week
double
company_id
keyword
complexity
double
converted
boolean
created_at
date
created_year
double
days_created_to_forecast
double
days_forecast_to_first_order
double
days_since_last_comment
double
first_order_created_at
date
first_order_id
long
forecast_date
date
important
keyword
is_sales_plan
keyword
label
integer
manager_id
keyword
manager_name
keyword
probability_source
keyword
probability_value
double
project_age_days
double
project_id
long
project_name
keyword
project_status
keyword
project_status_id
keyword
property_id
keyword
sector
keyword
type_of_calculation
keyword
deal_conversion_predictions_v1 — Предсказания вероятности конверсии (модель против оценки менеджера)
Документов: 1 255
as_of_date
date
created_at
date
features
object
forecast_date
date
manager_id
keyword
manager_name
keyword
manager_probability
double
model_name
keyword
predicted_probability
double
probability_delta
double
project_id
long
project_name
keyword
project_status
keyword
project_similarity_embeddings_v1 — Эмбеддинги проектов (knn_vector: content + structured) для поиска похожих
Документов: 20 371
account_id
keyword
account_name
text + .keyword
amount
double
amount_log
float
comment_count
integer
comment_count_log
float
comment_span_days
float
comments_per_week
double
content_embedding
knn_vector
content_hash
keyword
content_text
text
created_at
date
created_year
integer
days_since_last_comment
float
embedding_dimensions
integer
embedding_model
keyword
embedding_provider
keyword
execution_days
double
first_order_created_at
date
first_order_id
long
forecast_date
date
forecast_horizon_days
double
has_order
boolean
has_order_value
double
manager_id
keyword
manager_name
keyword
order_item_count
integer
order_item_count_log
float
probability
double
project_age_days
double
project_id
long
project_name
text + .keyword
project_status
keyword
project_status_id
keyword
property_id
keyword
property_name
text + .keyword
sector
keyword
structured_vector
knn_vector
type_of_calculation
keyword
project_similarity_vectors_v1 — Векторы сходства проектов (knn_vector)
Документов: 20 356
account_id
keyword
account_name
text + .keyword
amount
double
amount_log
float
comment_count
integer
comment_count_log
float
comment_span_days
float
comments_per_week
double
content_hash
keyword
content_text
text
content_vector
knn_vector
created_at
date
created_year
integer
days_since_last_comment
float
execution_days
double
first_order_created_at
date
first_order_id
long
forecast_date
date
forecast_horizon_days
double
has_order
boolean
has_order_value
double
manager_id
keyword
manager_name
keyword
order_item_count
integer
order_item_count_log
float
probability
double
project_age_days
double
project_id
long
project_name
text + .keyword
project_status
keyword
project_status_id
keyword
property_id
keyword
property_name
text + .keyword
sector
keyword
structured_vector
knn_vector
type_of_calculation
keyword
project_similarity_cards_v1 — Карточки проектов для выдачи похожих (токенизированные)
Документов: 20 353
account_id
keyword
account_name
text + .keyword
amount
double
amount_log
double
created_at
date
created_year
integer
execution_days
double
first_order_created_at
date
first_order_id
long
forecast_date
date
forecast_horizon_days
double
has_order
boolean
manager_id
keyword
manager_name
keyword
order_item_count
integer
probability
double
project_age_days
double
project_id
long
project_name
text + .keyword
project_status
keyword
project_status_id
keyword
property_id
keyword
property_name
text + .keyword
sector
keyword
token_text
text
tokens
keyword
type_of_calculation
keyword
project_similarity_comment_drafts_v1 — Черновики рекомендательных комментариев (nested similar_projects)
Документов: 426
comment_text
text
created_at
date
draft_id
keyword
send_result
object
sent_at
date
similar_projects
nested
source
keyword
status
keyword
target_project_id
long
target_project_name
keyword