Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use elasticsearch with react native?

I want to use elasticsearch for my mobile app (android and ios).

I installed elasticsearch-js using Node.js : https://github.com/elastic/elasticsearch-js

But I couldn't manage to make it works. So I made some researches and I read that it was a bad idea to "directly" use elasticsearch on mobile and that it was better to use an API.

I don't understand: elasticsearch-js is not already what I need ? If it is not the case then what should I use ?

In advance thanks

like image 862
K Soze Avatar asked Dec 07 '17 16:12

K Soze


1 Answers

Elasticsearch has to be back end. It's not something you install on a mobile or something. The minimum spec to have something working in production is like 5 instances of ES with 8Go of ram and 1 to 2 vCPU per server.

Elasticsearch has an API that you can call to have real time search. You can also tune the system to have suggestions or fuzzy searches (and even more). An ebook is available online for more info : https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html

It's not a plugin that you can add in the front.

On your app (Desktop/Web/Mobile) you need to implement an input where you do a specific search based on what the user writes inside it.

It's like an intern google engine (the principle between Google and ES are the same). You build the server and implement its API on your front.

I can give you a hand to install ES.

For React side as I said you can you consume the API : https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html

But there is npm package that handle that for you. Read this tutorial (with React but I'm pretty sure you can use this for your project) : https://codeburst.io/how-to-build-an-e-commerce-search-ui-with-react-and-elasticsearch-a581c823b2c3

like image 127
Ragnar Avatar answered Oct 24 '22 07:10

Ragnar