Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

99
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda