Skip to main content

Схема индексов OpenSearch — Grace CRM Assistant

Версия: 1.0 Дата: 4 мая 2026

Источник: OpenSearch http://localhost:9200 файл 01_opensearch_schema.md

Всего индексов: 15


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_users​itech_calculations ── project_id ──► itech_projectsitech_orders ──────── project_id ──► itech_projectsitech_order_items ─── order_id ────► itech_ordersitech_expected_payments ─ order_id ► itech_orders​itech_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 Чтение