Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!