Nama ERP DocsNama ERP Docs
Home
Namasoft.com
Data Model
GitHub
Home
Namasoft.com
Data Model
GitHub
  • Home

    • Search
    • Guides

      • List Views
      • Entity Flows
      • الفواتير والضرائب والخصومات
      • Supply Chain
      • e-commerce integration (Magento)
      • .
    • Examples
    • Reprocessing Transactions
    • Frequently Asked Questions
    • AI Generated Entity Flows Documentation

      • Core
      • Accounting Module
      • AI Module

        • EAEmbedFileToAIDB
        • EAEmbedRecordsFromQuery
        • .
      • Contracting Module
      • CRM Module
      • EGTax Reader Module
      • Freight Management System Module
      • Hospital Management System Module
      • HR Module
      • e-commerce Integration Module
      • Manufacturing Module
      • POS Module
      • Real Estate Module
      • Service Center Module
      • Supply Chain Module
      • .
    • Release Notes

      • 2016
      • 2017
      • 2018
      • 2019
      • 2020
      • 2021
      • 2022
      • 2025
      • .
    • Video Tutorials

      • Supply Chain Videos
      • Report Wizard Videos
      • Human Resources Videos
      • .

EAEmbedRecordsFromQuery

This document was generated using Claude.ai

Overview

Description: This entity flow processes database records to create AI embeddings (vector representations) for search and AI-powered features. It takes a SQL query that returns entity types and record IDs, then processes each record to generate embeddings that can be used for semantic search, similarity matching, and other AI operations.

Module: ai

Full Class Name: com.namasoft.modules.ai.util.actions.EAEmbedRecordsFromQuery

Parameters

The entity flow requires two parameters:

  1. Parameter 1: - (not used)
  2. Parameter 2: Records To Embed Query
    • A SQL query that must return exactly two columns:
      • Column 1: entityType - The entity type name (e.g., 'CRMLead', 'Customer', 'Item')
      • Column 2: id - The unique ID of the record to embed

How It Works

What are AI Embeddings?

AI embeddings are numerical representations (vectors) of text content that capture semantic meaning. They allow the system to understand and compare the meaning of different records, enabling features like:

  • Semantic search ("find customers similar to this one")
  • Content recommendations
  • Automated categorization
  • Intelligent matching

Processing Flow

  1. Query Execution: The system executes your SQL query against the database
  2. Record Processing: For each row returned:
    • Extracts the entity type and record ID
    • Loads the complete record from the database
    • Processes the record's text content to generate embeddings
    • Stores the embeddings for future AI operations
  3. Progress Tracking: Shows progress like "Embedding record 15 of 100"
  4. Transaction Safety: Each record is processed in its own database transaction

Important Notes

  • The system only processes records that don't already have embeddings or need updates
  • Large queries may take significant time to process
  • Each record is processed individually, so 1000 records = 1000 separate operations
  • The system shows progress updates during processing

SQL Query Requirements

Your query must follow this exact structure:

SELECT entityType, id
FROM [TableName]
WHERE [your conditions]

Required Columns

Column NameTypeDescriptionExample Values
entityTypeVARCHAREntity type name (case-sensitive)'CRMLead', 'Customer', 'Item'
idBIGINTRecord's unique identifier12345, 67890

Common Usage Examples

Example 1: Process Recent CRM Leads

SELECT 'CRMLead' as entityType, id
FROM CRMLead
WHERE lastUpdateDate >= '2025-09-01'
AND committed = 1

Example 2: Process Customer Records by Date Range

SELECT 'Customer' as entityType, id
FROM Customer
WHERE creationDate BETWEEN '2025-01-01' AND '2025-09-30'
AND active = 1

Example 3: Process Multiple Entity Types

SELECT 'CRMLead' as entityType, id FROM CRMLead WHERE lastUpdateDate >= '2025-09-01'
UNION ALL
SELECT 'Customer' as entityType, id FROM Customer WHERE lastUpdateDate >= '2025-09-01'
UNION ALL
SELECT 'Supplier' as entityType, id FROM Supplier WHERE lastUpdateDate >= '2025-09-01'
Edit On github
Last Updated:: 9/25/25, 10:57 AM
Prev
EAEmbedFileToAIDB
Next
.