Giter Site home page Giter Site logo

elastic / pycon-2021-workshop-app-search Goto Github PK

View Code? Open in Web Editor NEW
6.0 5.0 3.0 2.57 MB

Searchable Django Applications with Elastic App Search

Home Page: https://us.pycon.org/2021/schedule/presentation/45

License: Apache License 2.0

Python 98.59% HTML 1.41%
pycon pycon2021 python app-search elastic-app-search

pycon-2021-workshop-app-search's Introduction

Searchable Django Applications with Elastic App Search (PyCon US 2021)

Where are the slides for the Workshop?

Here they are!

What to do before the Workshop?

  • Fork / Clone the repository

    • $ git clone https://github.com/elastic/pycon-2021-workshop-app-search
    • $ cd pycon-2021-workshop-app-search
  • Create a virtual environment and install all dependencies in requirements.txt:

    • $ python -m venv venv
    • $ source venv/bin/activate
    • $ (venv) python -m pip install -r requirements.txt
  • Start an Enterprise Search instance. There are two options here:

    • Create an Elastic Cloud account (comes with a 14 day free trial no credit card required)
    • Install docker-compose and use docker-compose up to start an Enterprise Search instance locally
  • Update the url and private_key values in config.yml per the instructions for starting the Enterprise Search instance below.

  • Make sure at least examples/example_1_making_requests.py is able to run completely. You should see the message Everything worked! :-) in your terminal. All examples are meant to be run via python examples/example_N_...py or via the "Run" functionality in your IDE.

Starting an Enterprise Search instance

Elastic Cloud

  • Create an Elastic Cloud account
  • Create a new Deployment using the "Enterprise Search" template
  • Select a cloud provider and region and select Create Deployment. The instance will be provisioned and available in a few minutes
  • Click Launch or Copy Endpoint in the new deployment overview and copy the URL (minus the /login path). The result should look like approximately this: https://(deployment name)-1a6dc7.ent.us-west1.gcp.cloud.es.io
  • Open config.yml and set url field to be "https://(deployment name)-1a6dc7.ent.us-west1.gcp.cloud.es.io" and run the script and ensure it passes without error.
  • Select Launch App Search, from here you'll be placed in a getting started screen. You can follow these steps if you'd like otherwise you can select Skip Onboarding in the top.
  • That's it, you're now in App Search!

Docker Compose

  • Download and install docker-compose
  • With an open terminal in the cloned git repository run docker-compose up. Wait for all services to spin up and configure for the first time which may take a minute.
  • You should be able to connect to http://localhost:3002 in a browser
  • Open config.yml and set url field to be "http://localhost:3002" and run the script and ensure it passes without error.
  • The username will be enterprise_search and the password will be changeme.
  • Select Launch App Search, from here you'll be placed in a getting started screen. You can follow these steps if you'd like otherwise you can select Skip Onboarding in the top.
  • That's it, you're now in App Search!

Finding your Private Key

  • When in App Search, navigate to the Credentials tab
  • Click the Copy to Clipboard button next to the Private Key
  • Paste the value into the private_key field in config.yml

Getting Started with the Django App

Setup

  • Ensure your virtualenv is activated and requirements.txt is installed
  • Change directory into django/
  • Run python manage.py migrations to create db.sqlite3
  • Run python manage.py runserver to start the server on http://localhost:8000. Don't use these exact configurations in production!
  • Access http://localhost:8000/reset to load data into the Django database

URLs of Interest

Indexing Models into App Search

See django/parks/models.py for the signals approach to indexing documents in App Search. See django/parks/tasks.py for the tasks approach to indexing documents in App Search.

When doing this in real life I recommend using background tasks for signal handlers to avoid blocking web requests.

Reference UI

The Reference UI has been generated and the production compressed JS and CSS are stored in django/static/. When you're creating your own Reference UI you should not copy these and instead follow the instructions on the Reference UI repository.

pycon-2021-workshop-app-search's People

Contributors

sethmlarson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.