Skip to content

Docker Setup and Test Elasticsearch Locally

tmpayton edited this page Jan 14, 2025 · 3 revisions

To setup and test Elasticsearch locally:

  1. Open the rancher desktop application
  2. If the image hasn't been built, run the build process: docker-compose build
  3. Start services: docker-compose up -d openfec db elasticsearch

Creating Indices:

  • docker-compose exec openfec python cli.py create_index <index_name>
    • docker-compose exec openfec python cli.py create_index case_index
    • docker-compose exec openfec python cli.py create_index ao_index
    • docker-compose exec openfec python cli.py create_index arch_mur_index

Displaying Indices:

  • docker-compose exec openfec python cli.py display_index_alias

Display Mappings:

  • python cli.py display_mapping <index_name>
    • docker-compose exec openfec python cli.py display_mapping case_index
    • docker-compose exec openfec python cli.py display_mapping ao_index
    • docker-compose exec openfec python cli.py display_mapping arch_mur_index

Delete Index:

  • docker-compose exec openfec python cli.py delete_index <index_name>
    • docker-compose exec openfec python cli.py delete_index case_index
    • docker-compose exec openfec python cli.py delete_index ao_index
    • docker-compose exec openfec python cli.py delete_index arch_mur_index

Upload Documents

  • Current MURs:
    docker-compose exec openfec python cli.py load_current_murs (upload all current murs docs)
    docker-compose exec openfec python cli.py load_current_murs <mur_no>(upload single current mur doc)
    • docker-compose exec openfec python cli.py load_current_murs 7212
  • Archived MURs:
    docker-compose exec openfec python cli.py load_archived_murs (upload all archived mur docs)
    docker-compose exec openfec python cli.py load_archived_murs <mur_no> (upload single archived murs doc)
    • docker-compose exec openfec python cli.py load_archived_murs 400
  • Advisory Opinions:
    docker-compose exec openfec python cli.py load_advisory_opinions <YYYY-MM> (this command will load AO docs from YYYY-MM to current time)
    • docker-compose exec openfec python cli.py load_advisory_opinions 2024-12
  • Statues:
    docker-compose exec openfec python cli.py load_statutes
  • Admin Fines:
    docker-compose exec openfec python cli.py load_admin_fines (upload all admin fines docs)
    docker-compose exec openfec python cli.py load_admin_fines <admin_fines_no> (upload single admin fine doc)
    • docker-compose exec openfec python cli.py load_admin_fines 3314
  • ADRs:
    docker-compose exec openfec python cli.py load_adrs (upload all adr docs)
    docker-compose exec openfec python cli.py load_adrs <adr_no> (upload single adr doc)
    • docker-compose exec openfec python cli.py load_adrs 008

Test Endpoints:


Show all legal data: http://127.0.0.1:5000/v1/legal/search/


Test filter by type:
http://127.0.0.1:5000/v1/legal/search/?type=advisory_opinions
http://127.0.0.1:5000/v1/legal/search/?type=murs
http://127.0.0.1:5000/v1/legal/search/?type=adrs
http://127.0.0.1:5000/v1/legal/search/?type=admin_fines
http://127.0.0.1:5000/v1/legal/search/?type=regulations
http://127.0.0.1:5000/v1/legal/search/?type=statutes
http://127.0.0.1:5000/v1/legal/search/?type=murs&mur_type=archived
http://127.0.0.1:5000/v1/legal/search/?type=murs&mur_type=current

You can also view indices and documents by using the Elasticsearch GUI. See the Elasticsearch GUI document for more information, however the cors setting are set automatically by the docker-compose file.

Running Commands in Service

The above examples the command docker-compose exec <Service> <Command> to run commands in service containers. Alternately, commands can be run directly in the Exec tab of a service in docker desktop.