0

I have indexed data from firebase via elasticSearch . And Its Working Properly .

Now I am Searching data via firebase below cloud function :

exports.searchIt = functions.database.ref('/search/{key}')
                .onUpdate(event => {

                    let key=event.params.key;

                    let elasticSearchConfig = functions.config().elasticsearch;

                    const esClient = new elastic.Client({
                      host: 'http://35.198.221.164',
                      log: 'error'
                    });

                    console.log('client Created');

                    let searchBody = {
                        size: 20,
                        from: 0,
                        query: {
                          match_all: {}
                        }
                      };


                    esClient.search({index: 'offers', body: searchBody})
                    .then(results => {
                        console.log('Successfully Entered');
                        results.hits.hits.forEach(
                          (hit, index) => console.log(hit)
                        )
                      })
                      .catch(console.error);

                });

But this gives error below :

textPayload: "{ Error: Not Found at respond (/user_code/node_modules/elasticsearch/src/lib/transport.js:307:15) at checkRespForFailure (/user_code/node_modules/elasticsearch/src/lib/transport.js:266:7) at HttpConnector. (/user_code/node_modules/elasticsearch/src/lib/connectors/http.js:159:7) at IncomingMessage.bound (/user_code/node_modules/elasticsearch/node_modules/lodash/dist/lodash.js:729:21) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9)

And on changing host to any other it still create client.

Why is this happening?

5
  • this is not related to android
    – user8466383
    Aug 31, 2017 at 17:51
  • I would suggest to not post your actual ip!
    – dshockley
    Aug 31, 2017 at 18:01
  • Can you post the output of running curl -XGET http://<your ip>/_search? (From the same machine where the node.js code is failing.)
    – dshockley
    Aug 31, 2017 at 18:04
  • Error Solved. I forgotten to add "/elasticsearch" to host.
    – dkp1997
    Sep 1, 2017 at 7:16
  • Formatted error as quote. Removed Android tag. Sep 2, 2017 at 18:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.