Estuary

How to Sync SQL Server to Elasticsearch: Load Data in 2 Easy Steps

This guide explores the step-by-step process of different methods to sync data from SQL Server to Elasticsearch to suit your varied requirements.

SQL Server to elasticsearch - Blog Hero Image
Share this article

Syncing SQL Server data to Elasticsearch lets you keep SQL Server as your system of record while using Elasticsearch as a fast search and analytics layer. This setup is useful for full-text search, operational dashboards, log analysis, and low-latency application queries.

In this tutorial, we’ll explore the main ways to sync SQL Server data to Elasticsearch, how each method works, and which approach best fits your use case.

For a broader view beyond SQL Server, see how to ingest data into Elasticsearch using Logstash, the REST and Bulk API, or real-time CDC.

SQL Server to Elasticsearch Data Mapping Considerations

Before syncing SQL Server data into Elasticsearch, decide how relational tables should become Elasticsearch documents. SQL Server stores data in normalized tables with rows, columns, primary keys, and joins. Elasticsearch stores denormalized JSON documents optimized for search.

Key mapping decisions include:

  • Primary keys: Use the SQL Server primary key as the Elasticsearch document ID to avoid duplicate documents during updates.
  • Data types: Map SQL Server integers, decimals, floats, dates, booleans, and strings to the closest Elasticsearch field types.
  • Text vs keyword: Use text for fields that need full-text search, such as names, descriptions, or notes. Use keyword for fields used in filters, sorting, joins, status values, IDs, and categories.
  • Dates and timestamps: Ensure SQL Server datetime, datetime2, and date fields are formatted consistently before indexing.
  • Denormalization: If Elasticsearch queries need data from multiple SQL Server tables, join or transform that data before indexing so each Elasticsearch document contains the fields needed for search.
  • Deletes: Make sure your pipeline can propagate deletes, or use a soft-delete field such as deleted_at and filter deleted records from search results.
  • Schema changes: Plan how new columns, renamed fields, or changed data types in SQL Server should be handled in Elasticsearch mappings.

For production search applications, define Elasticsearch mappings intentionally instead of relying only on dynamic mapping. This helps avoid mapping conflicts and improves filtering, sorting, aggregations, and relevance tuning.

How to Load Data From SQL Server to Elasticsearch

Let’s look into the different methods of moving data from SQL Server to Elasticsearch. 

MethodBest forFreshnessComplexity
EstuaryManaged SQL Server to Elasticsearch CDC pipelinesReal-timeLow
SSISMicrosoft teams building custom batch-oriented workflowsBatch or scheduledMedium to high
  • Method 1: Using Estuary to connect SQL Server to Elasticsearch
  • Method 2: Using SSIS to load data from SQL Server into Elasticsearch 

Method 1: Using Estuary for SQL Server to Elasticsearch Integration

The first method uses Estuary, a no-code data integration platform with built-in connectors for SQL Server and Elasticsearch. This section shows how to use Estuary to capture SQL Server changes with CDC and continuously materialize them into Elasticsearch.

Prerequisites

Step 1: Configure SQL Server as the Source

  • Register for a new Estuary account or log in to your existing one.
  • Select the Sources option from the left navigation pane of the dashboard.
  • Click the + NEW CAPTURE button on the Sources page.
SQL Server to elasticsearch - Create Capture
  • Type SQL Server in the Search connectors box and click the connector’s Capture button when it appears in the search results.
SQL Server to elasticsearch - Sources Specify Details
  • On the SQL Server connector configuration page, enter the required details, such as Name, Server Address, User, Password, and Database.
  • Click NEXT > SAVE AND PUBLISH to finish configuring the source. This CDC connector will continuously capture updates in your SQL Server database into one or more Flow collections.

Step 2: Configure Elasticsearch as the Destination

  • After configuring the source, the next step is to setup the destination end of the integration pipeline. Click MATERIALIZE COLLECTIONS in the pop-up window that appears after a successful capture.

You can also select the Destinations option from the left-hand pane of the dashboard.

  • On the Destinations page, click the + NEW MATERIALIZATION button.
SQL Server to elasticsearch - Create Materialization
  • Next, type Elastic in the Search connectors box, and click the Materialization button of the connector in the search results.
SQL Server to elasticsearch - Endpoint Config
  • On the Create Materialization page, enter the necessary information, including Name, Endpoint, Username, and Password.
  • To manually link a capture to your materialization, use the SOURCE FROM CAPTURE option in the Source Collections section.
  • Finally, click NEXT > SAVE AND PUBLISH to complete the configuration process. The connector will materialize Flow collections of your SQL Server data into indices in an Elasticsearch cluster.

To gain a better understanding of Estuary, refer to the following documentation:

Benefits of Estuary

  • Wide Range of Connectors: Estuary offers 200+ pre-built connectors for effortless configuration. You can leverage these connectors to merge data from several sources to a destination without writing a single line of code.
  • Scalability: It is designed to handle large data flows and supports up to 7 GB/s.
  • Real-Time Data Processing: Estuary supports continuous, real-time data transfer from SQL Server to Elasticsearch. This helps ensure that the most recent data is being used by downstream apps, enabling real-time decision-making.
  • Change Data Capture: It uses log-based Change Data Capture (CDC) to capture fine-grained inserts, updates, and deletes from SQL Server with minimal impact on the source database.

Ready to elevate your data capabilities? Start syncing SQL Server to Elasticsearch with Estuary for real-time, seamless integration.

Method 2: Using SSIS to Load Data From SQL Server to Elasticsearch

Microsoft offers SQL Server Integration Services (SSIS), a potent toolkit for data integration and transformation. It allows programmers and data experts to plan, create, implement, and oversee intricate workflow and data integration solutions.

Before you set up a SQL Server to Elasticsearch workflow using SSIS, ensure the following prerequisites are in place.

  • Install and configure SSIS in your SQL Server environment.
  • Ensure access to SQL Server Management Studio (SSMS) to create and manage SSIS packages.
  • Set up and configure Elasticsearch to receive the moved data.

Step 1: Import Data from SQL Server

  • Create a new SSIS package and drag a Data Flow Task from the SSIS Toolbox into the Control Flow.
SQL Server to elasticsearch - Control Flow page

Image Source

  • After opening the Data Flow Task, add OLE DB Source.
  • Configure the OLE DB Source to pull information from a table. For example, the Products table in the Northwind database.
  • Select the columns you need. For this guide, consider ProductName and ProductID.
SQL Server to elasticsearch - Flow Page

Image Source

Step 2: Convert Data into JSON Documents

Use JSON Generator Transform to prepare the data before adding it to Elasticsearch. It will assist in creating JSON documents from the SQL table rows.

Step 3: Create Index Data for the Elasticsearch Bulk API

  • After closing the window, drag the Derived Column component from the SSIS Toolbox.
  • Create two additional columns and name them RowFooter and RowHeader.
SQL Server to elasticsearch - Derived Column Transformation editor page

Image Source

  • Provide the columns with values in the Expression column:
plaintext
"{ \"index\": { \"_index\": \"shop\", \"_id\" : \"" + (DT_WSTR,100)ProductID + "\" } }\n"
  • Next, drag the JSON Generator Transform from the SSIS toolbox and open it.
  • Right-click on Mappings, then choose Add Element(s) (Below this node).
SQL Server to elasticsearch - Add elements page

Image Source

  • Select ProductName in the Source Column and name as the Output Alias in the dialog box.
SQL Server to elasticsearch - Add or Edit Attribute page

Image Source

  • Ensure your view is similar to this.
SQL Server to elasticsearch - JSON Generator transform page

Image Source

  • Next, select the Header / Footer tab.
    • Choose the Direct String option.
    • Input <%RowHeader%> in Header String
    • Input <%RowFooter%> in Footer String.
SQL Server to elasticsearch - Select direct string page
  • Then, close the window.

Step 4: Use JSON String to Update the Bulk API Call’s Index Data

  • From the steps mentioned for Create Index Data for the Elasticsearch Bulk API, complete all the steps except for step 2. Instead, use the expressions below for RowHeader and RowFooter.
SQL Server to elasticsearch - derived column transform editor page
  • Configure the Derived Column to add a prefix. In the Expression column, provide the header and footer to the JSON.

RowHeader:

plaintext
"{ \"update\": { \"_index\": \"shop\", \"_id\" : \"" + (DT_WSTR,100)ProductID + "\" } }\n{ \"doc\" : "

RowFooter:   "}\n"

Step 5: JSON String for Index Data Deletion for the Bulk API Call

  • Follow the first two steps in Step 3: Create Index Data for the Elasticsearch Bulk API.
  • For the second step in Step 3, use the expression below for RowHeader.
  • Configure derived columns to add a prefix and the header and footer to a JSON.
SQL Server to elasticsearch - configure derived column page
  • Provide them values in the Expression column.

RowHeader:

plaintext
"{ \"delete\": { \"_index\": \"shop\", \"_id\" : \"" + (DT_WSTR,100)ProductID + "\" } }\n"

Step 6: Integrate SQL Server and Elasticsearch

  • Drag the Web API Destination component into the Data Flow for editing.
  • Press <New ZS-HTTP Connection> in Select Connection.
  • When the HTTP Connection Manager window opens, configure the connection to your Elasticsearch instance:
  • Configure a Web Url that points to your Elasticsearch instance.
  • Select Basic - UserID/Password under Credentials Type.
  • Then, set your password and username.
SQL Server to elasticsearch - SQL Server to elasticsearch -
  • Close the configuration window and set up a Web API Destination.
  • Here are the steps for importing those rows into Elasticsearch:
  • Set the Input Column for Body to ZS_JSON_OUT for Create and Update Index Data and to RowHeader [Derived Column] for Delete Index Data.
  • Set the URL to http://localhost:9200/_bulk.
  • Set the HTTP Request Method as POST.
SQL Server to elasticsearch - web API destination page
  • In the Batch settings (For Body) tab,
  • Enable batch submission.
  • Set the Body Batch Size, let’s say, to 1000. Ensure this is an even number to avoid any issues.
SQL Server to elasticsearch - Web API destination 2 page

By following these steps, you can successfully load data from SQL Server to Elasticsearch.

Limitations of Using SSIS for SQL Server to Elasticsearch Sync

  • Limited real-time support: SSIS is better suited for batch and scheduled workflows than continuous low-latency sync. If your Elasticsearch index needs to reflect SQL Server changes immediately, a CDC-based approach is a better fit.
  • Delete handling: SSIS workflows must explicitly handle deleted SQL Server rows. Without a delete strategy, removed records can remain in Elasticsearch and appear in search results.
  • Mapping complexity: SQL Server data types do not always map cleanly to Elasticsearch field types. Text fields, decimals, dates, and nullable values need careful handling.
  • Operational overhead: SSIS packages require deployment, monitoring, retry handling, and maintenance when schemas change.
  • Performance tuning: Large tables, frequent syncs, and complex transformations can increase runtime and require batching, indexing, and network tuning.

Conclusion

Syncing SQL Server to Elasticsearch lets teams keep SQL Server as the transactional system of record while using Elasticsearch for fast search, filtering, and analytics.

You can build this pipeline with SSIS if your team already uses Microsoft data tooling and batch latency is acceptable. However, SSIS requires more manual configuration, custom delete handling, mapping work, and operational maintenance.

Estuary is a better fit when you want a managed, CDC-based pipeline that continuously captures SQL Server changes and materializes them into Elasticsearch with less infrastructure to operate.

If your Elasticsearch project also includes other relational databases, see our guides to streaming PostgreSQL to Elasticsearch, syncing MySQL to Elasticsearch, and moving Oracle data to Elasticsearch.

Looking to sync SQL Server and other sources into Elasticsearch without custom pipeline maintenance? Log in or register to get started with Estuary.

FAQs

How do I design effective data mapping in Elasticsearch?

Select data types in Elasticsearch that closely match the datatypes in your SQL Server tables. Utilize Elasticsearch’s nested objects and arrays to represent hierarchical relationships within SQL Server data effectively.

How does the performance of Elasticsearch compare to SQL Server for typical use cases?

Elasticsearch is designed to execute searches and retrievals quickly, particularly for use cases involving full-text search and analytics. Performance comparisons can change based on query methods, data amount, and use cases.

Start streaming your data for free

Build a Pipeline

About the author

Picture of Rob Meyer
Rob MeyerTechnical Product Marketing (Data & Integration)

Rob is a technical product marketing leader with expertise in data engineering, databases, and integration technologies. He has previously worked with WSO2, Firebolt, Imply, GridGain, Axway, Informatica, and TIBCO, focusing on data platforms, APIs, and real-world data movement solutions.

Streaming Pipelines.
Simple to Deploy.
Simply Priced.
$0.50/GB of data moved + $.14/connector/hour;
50% less than competing ETL/ELT solutions;
<100ms latency on streaming sinks/sources.