Tuesday 22 November 2016

ELI5: Elasticsearch with Javascript. I think I need to use node.js - Not sure I get it...

In a tutorial here it says:Elasticsearch provides an official module for Node.js, called elasticsearch. First, you need to add the module to your project folder, and save the dependency for future use.npm install elasticsearch --saveThen, you can import the module in your script as follows:const elasticsearch = require('elasticsearch');What is "your script"? I know I'm missing something here but I can't figure out what it is. I probably came at this backwards (populating my elasticsearch indexes with python and then thinking about searching it it in JavaScript). I also wasted most of my day trying to figure out django and got pretty far but when it got to the templates and doing 'for' loops with dict() objects I just about lost my mind.I am kind of new to Python but have been using Perl or PHP for 15 years. It's time to update my toolbox.My basic goal is to have an elasticsearch cluster and build a tool to search it etc... I'm sure I can do the JavaScript part but I don't want the browsers accessing elasticsearch directly of course. For this reason I'm pretty sure I need to use node.js. I just have no clue what that means.I've been reading about npm and node.js but I really don't understand how node.js will provide server side javascript.Some of the reading I've done:http://ift.tt/2gjDcci of them really tell you what it means to run a node.js server and how the node_modules installed with npm get used by node.js and how to interact with node.js using javascript in .html files on my webserver. I'm thinking I need to make AJAX calls to the node.js server with the web server that the browsers are using. Am I looking at this the wrong way? Is my understanding of node.js, however limited, also wrong? Should I even be using node.js?I want to avoid using php although I've used it for years. I may have to resort to using python as a CGI but that's just as terrible an idea.

Submitted November 23, 2016 at 01:14AM by DamagedFreight

No comments:

Post a Comment