Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use entity framework with elastic search

I want to use on entity framework with elastic search.

I saw this article MVC APPLICATION WITH ENTITY FRAMEWORK AND ELASTICSEARCH.

But as I understood, I need 2 DB (ms sql+ elastic) and there they explain how to translate the data.

The ms sql I will save the data and I done the search on the elastic .

So all the data will be twice so it will be waste of storage...

Is there any direct way to do that?

thanks

like image 401
SADI1987 Avatar asked Dec 04 '16 22:12

SADI1987


2 Answers

You can use entity framework with elastic search by utilising ElasticsearchCrud api.

This article clearly explains the steps to do so.

P.S: I rather not to copy/paste the steps here as it might look redundant.

like image 161
Benjamin Avatar answered Oct 04 '22 15:10

Benjamin


Yes you understood right you would need to use two different sources. There is no direct way to use elasticsearch with EF, you would need to write you custom logic to fit Database and Elasticsearch together.

If you ask why? Answer is that Database and Elasticsearch are different.

First of all Elastic is document database and you should save whole object while in database you can split items to multiple tables in ES "preferable" to save as a one document (Still in ES you can use nested objects but you will not be able to join).

Secondly search queries are totally different in SQl and Elastic. So sometimes only you would decide which source should be used to search. To search Elastic you can use NEST package but you would need to learn ES queries and indexing part since depends on analysis you will have defferent results.

like image 35
Vova Bilyachat Avatar answered Oct 04 '22 17:10

Vova Bilyachat