Giter Site home page Giter Site logo

search_as_you_type's Introduction

demo

Search As You Type (Elasticsearch)

Demo code and sample employees data to implement the "Search as you type" feature on elasticsearch.

Written the middleware API in python using flask. Used JQuery for javascript operations.

Installation

Assuming you have successfully installed Elasticsearch and Kibana on your machine and it is working perfectly. Kindly refer respective installation document.

OR

You can run Elasticsearch on the cloud with a few clicks.

Install Python3 & pip3

  1. Refer Document to install python3 & pip3 on your system.
  2. Install flask
pip3 install flask
  1. Install elasticsearch package
pip3 install elasticsearch

git Clone

git clone https://github.com/ashishtiwari1993/search_as_you_type.git
cd search_as_you_type

Create Index and load data

Make sure Elasticsearch and kibana are up and running fine on your machine.

Create Index

PUT /sayt?pretty
{
  "mappings": {
    "properties": {
      "first_name": {
        "type": "search_as_you_type"
      },
      "last_name": {
        "type": "search_as_you_type"
      },
      "street_address": {
        "type": "search_as_you_type"
      },
      "company": {
        "type": "search_as_you_type"
      },
      "email": {
        "type": "search_as_you_type"
      }
    }
  }
}

Load sample data

Sample data.json file is given which need to load with the help of bulk API.

curl -s -H "Content-Type: application/x-ndjson" --cacert /path/to/http_ca.crt  -u "username:password" -XPOST "https://localhost:9200/_bulk" --data-binary "@data.json"

Do not forget to change the elasticsearch's endpoint.

Run api.py & test

Open api.py and change elasticsearch endpoint accordingly.

es = Elasticsearch(
    "https://localhost:9200",
    ca_certs = "path/to/ca_certificate",
    basic_auth = ("username", "password")
)

Start API Server

python3 api.py

This will start the API service on port 5001.

Open index.html on your browser.

Template files in the correct location

myproject/
    api.py
    templates/
        index.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.