Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
Need some help regarding the Elasticsearch engine and react js

I hope you are doing well, I need some help regarding the Elasticsearch engine. what I am doing is I am trying to create a search engine I have successfully post my data through kibana to elasticsearch engine. but "but how can I add the search component of elastyicsearch to my react app", I have like 4 million records into the kibana index, when I try to search directly from react it take a long time to display records into my frontapp app with nodejs api. below is the code with nodejs but the problem with this code it just gives me 10 records only.

router.get('/tweets', (req, res)=>{
let query = {
    index: 'tweets',
    // size: 10000
}
if(req.query.tweets) query.q = `*${req.query.tweets}*`;
client.search(query)
.then(resp => {
    return res.status(200).json({
        tweets: resp.body.hits.hits
    });
})
.catch(err=>{
    console.log(err);
    return res.status(500).json({
        err
    });
});

});

Is there any way to impliment elasticsearch component directly to my reactjs app. like with the localhost:9200/index.. directly from the elasticsearch api?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You could use SearchKit to directly query elasticsearch from you react app. But be aware that exposing DB services outside of your own infrastructure is bad practice.

You can use the component like this:

import {
  SearchkitManager,
  SearchkitProvider,
  SearchkitComponent
} from 'searchkit'

const searchkit = new SearchkitManager(host)

class Render extends SearchkitComponent {

  render(){
    let results = await this.searchkit.reloadSearch()
    return <div>{results}</div>
  }

}

function table(){

  return <SearchkitProvider searchkit={searchkit}>
            <Render />
          </SearchkitProvider>
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Your request to Elasticsearch looks a bit strange to me, have you tried to search using a body like in the documentation? This line:

if(req.query.tweets) query.q = `*${req.query.tweets}*`;

doesn't seem like a correct way to write a query. Which field do you want to search for?

I saw that you tried to use the size field, which should be correct. You can also try the following:

client.search({
  index: 'tweets',
  body: {
    size: 1000, // You can put the size here to get more than 10 results
    query: {
      wildcard: { yourfield: `*${req.query.tweets}*` }
    }
  }
}, (err, result) => {
  if (err) console.log(err)
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda