Build a Custom Search Engine with Node.js and Elasticsearch
Behrooz Kamali takes an in-depth look at elasticsearch—a scalable, high-performance search engine—demonstrating how to integrate it into a Node project.
Article url: https://www.sitepoint.com/search-engine-node-elasticsearch
Requirements
- Node.js (min version v0.11.0)
- Java Runtime Environment (min version 1.8)
- Elasticsearch
Installation Steps
- Clone repo
- Run
npm install
- Start Elasticsearch
More precise instructions can be found in the installation section of the article
List of files in this repo:
data.json
: sample data fileindex.js
: script for indexing the data in elasticsearchindices.js
: script to check indexing was successfulsearch_all.js
: return all documents in one or more indicessearch_match.js
: match documents that contain specific values in a fieldsearch_multi_match.js
: search within multiple fieldssearch_match_phrase.js
: match a complete phrasesearch_bool.js
: combining multiple queriesfilter.js
: basic filter functionalityaggregations.js
: demonstration of how aggregations worksuggest_term.js
: generate suggestions for search termssuggest_phrase.js
: generate suggestions for search phrases
License
The MIT License (MIT)
Copyright (c) 2016 SitePoint
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.