从sql服务器加载数据到弹性搜索

时间:2021-04-22 10:20:23

I'm new to elastic search and I have a basic question. I want to load data from database and search them by using elastic search in MVC.NET project, but cause of data I have in my database's table I cant't convert all of them to the json and search in thme by using elastic search. How should I fill data of the elastic search from the database in an mvc.net project. I don't want the whole solution because it is impossible just a general and brief explanation. thank you very much.

我是弹性搜索新手,我有一个基本问题。我想从数据库中加载数据,并使用MVC中的弹性搜索进行搜索。NET项目,但是由于我的数据库表中有数据,我不能将它们全部转换为json并使用弹性搜索在thme中进行搜索。如何从mvc.net项目的数据库中填充弹性搜索的数据。我不想要整个解决方案,因为它不可能只是一个简单的解释。非常感谢。

1 个解决方案

#1


1  

First of all you should be able to model your data from sql to Elasticsearch.As ES is no sql and document oriented database/search engine. You need an indexer job to index SQL data to Elasticsearch. Get all the columns associated with one record that you want to search in Elasticsearch from your SQL database(use joins if data is in multiple tabeles).use dedicated stored proc to get only needed data and construct a document class ,serialize to JSON and index in your Elasticsearch cluster.

首先,您应该能够将数据建模从sql到Elasticsearch。因为ES不是面向sql和文档的数据库/搜索引擎。您需要一个indexer作业来将SQL数据索引为弹性搜索。从SQL数据库中获取与一个记录相关联的所有列(如果数据在多个表中,则使用join)。使用专用的存储proc来获取所需的数据并构造一个文档类,将其序列化为JSON并在您的Elasticsearch集群中建立索引。

Use Elasticsearch.net client as they very neatly expose bulk index APIs.

使用Elasticsearch.net客户端,因为它们可以很好地公开大量索引api。

Hope this will get you started. Have fun

希望这能让你开始。玩得开心

#1


1  

First of all you should be able to model your data from sql to Elasticsearch.As ES is no sql and document oriented database/search engine. You need an indexer job to index SQL data to Elasticsearch. Get all the columns associated with one record that you want to search in Elasticsearch from your SQL database(use joins if data is in multiple tabeles).use dedicated stored proc to get only needed data and construct a document class ,serialize to JSON and index in your Elasticsearch cluster.

首先,您应该能够将数据建模从sql到Elasticsearch。因为ES不是面向sql和文档的数据库/搜索引擎。您需要一个indexer作业来将SQL数据索引为弹性搜索。从SQL数据库中获取与一个记录相关联的所有列(如果数据在多个表中,则使用join)。使用专用的存储proc来获取所需的数据并构造一个文档类,将其序列化为JSON并在您的Elasticsearch集群中建立索引。

Use Elasticsearch.net client as they very neatly expose bulk index APIs.

使用Elasticsearch.net客户端,因为它们可以很好地公开大量索引api。

Hope this will get you started. Have fun

希望这能让你开始。玩得开心