Skip to content

Opensearch 3.7.x setup and test locally

Priya Kasireddy edited this page Nov 25, 2026 · 1 revision

1. Install opensearch 3.7.x locally (The minimum supported JDK version is JDK 21)

  1. Install jdk@21
    run: brew install openjdk@21

  2. Check java version
    run: java -version
    openjdk@27 sample output shown as below:

 openjdk version "27.0.1.1" 2026-11-17
 OpenJDK Runtime Environment Homebrew (build 27.0.1.1)
 OpenJDK 64-Bit Server VM Homebrew (build 27.0.1.1, mixed mode, sharing)
  1. Add/update openjdk path in bash_profile
    run: export OPENSEARCH_JAVA_HOME=/opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk/Contents/Home

  2. Install opensearch**: Two versions available depending on Mac chip:

    For M1/M2 (ARM64)chips:

    run: curl -L -O https://artifacts.opensearch.org/releases/bundle/opensearch/3.7.0/opensearch-3.7.0-linux-arm64.tar.gz
    run: tar -zxf opensearch-3.7.0-linux-arm64.tar.gz
    run: cd opensearch-3.7.0
    run: cd bin

    For Intel-based Macs(x64)chips:

    run: curl -L -O https://artifacts.opensearch.org/releases/bundle/opensearch/3.7.0/opensearch-3.7.0-linux-x64.tar.gz
    run: tar -zxf opensearch-3.7.0-linux-x64.tar.gz
    run: cd opensearch-3.7.0
    run: cd bin

  3. Add the following to opensearch.yml file:
    plugins.security.disabled: true

  4. Start opensearch service:
    run: ./opensearch

  5. Test opensearch service. Copy the following url on a browser
    run: http://127.0.0.1:9200/

2. Setup openFEC repo environment

  1. Check out develop branch
    run: git checkout develop
  2. Create and activate a new virtual environment
    run: pyenv virtualenv <venv name>
    run: pyenv activate <venv name>
  3. Install project requirements
    run: pip install -r requirements.txt && pip install -r requirements-dev.txt
  4. Set SQLA_CONN to dev db
    run: export SQLA_CONN= $ provide the connection string for postgres dev database $
  5. Delete old node_modules
    run: rm -rf node_modules
  6. Install node dependencies
    run: npm i && npm run build

3. Create indexes, aliasas and index mappings commands

  1. Create index 'xxxx_index' and two aliases ('xxxx_alias' and 'search_alias')
    ex1: run: python cli.py create_index case_index
    ex2: run: python cli.py create_index ao_index
    ex3: run: python cli.py create_index arch_mur_index
    ex3: run: python cli.py create_index rm_index

4. Display opensearch resources commands

  1. Display index and alias:
    Inside a terminal window run: python cli.py display_index_alias
    Use browser, copy url: http://localhost:9200/_cat/indices?v
    Use browser, copy url: http://localhost:9200/_aliases?pretty
  2. Display mappings:
    Inside a terminal window:
    ex1: run: python cli.py display_mapping case_index
    ex2: run: python cli.py display_mapping ao_index
    ex3: run: python cli.py display_mapping arch_mur_index
    ex3: run: python cli.py display_mapping rm_index
    Use browser, copy url: http://localhost:9200/_mappings

5. Delete an index and its alias


ex1: run: python cli.py delete_index case_index
ex2: run: python cli.py delete_index ao_index
ex3: run: python cli.py delete_index arch_mur_index
ex3: run: python cli.py delete_index rm_index

6. Upload legal documents to local opensearch server

Notes:
a)The legal PDF files will not upload to the S3 bucket when running locally because there is no S3 connection in the local environment. Ignore any related warning messages.
b)You can un-comment this line (logger.setLevel(logging.DEBUG)) on the top of each upload python file to enable DEBUG mode.
c)All document types (OS mapping type) under index 'case_index':
'murs', 'adrs', 'admin_fines',
d)All document types (OS mapping type) under index 'ao_index':
'advisory_opinions', 'statutes'
e)The document type (OS mapping type) under index 'arch_mur_index': 'murs'
e)The document type (OS mapping type) under index 'rm_index': 'rulemakings'



1) Upload AO (advisory_opinions.py)
python cli.py load_advisory_opinions YYYY-MM
(this command will load AO docs from YYYY-MM to current time)
ex: run: python cli.py load_advisory_opinions 2020-03
Test on browser: http://localhost:9200/ao_index/_doc/2020-03



2) Upload current murs (current_case.py)
python cli.py load_current_murs (upload all current murs docs)
python cli.py load_current_murs <mur_no> (upload single current mur doc)
ex: python cli.py load_current_murs 7212
Test on browser: http://localhost:9200/case_index/_doc/mur_7212



3) Upload adrs (current_case.py)
python cli.py load_adrs (upload all adr docs)
python cli.py load_adrs <adr_no> (upload single adr doc)
ex: python cli.py load_adrs 008
Test on browser: http://localhost:9200/case_index/_doc/adr_008



4) Upload admin fines (current_case.py)
python cli.py load_admin_fines (upload all admin fines docs)
python cli.py load_admin_fines <admin_fines_no> (upload single admin fine doc)
ex: python cli.py load_admin_fines 3314
Test on browser: http://localhost:9200/case_index/_doc/af_3314



5) Upload statutes (statutes.py)
python cli.py load_statutes (upload all statutes docs)
There is no way to test statutes on browser.
You can use curl command to run in terminal:
curl -X GET "localhost:9200/ao_index/_search?pretty" -H 'Content-Type: application/json' -d'{"query": {"terms": {"_id": [ "/us/usc/t26/s9009", "/us/usc/t52/s30110"] }}}'



6) Upload archived MURs (archived_murs.py)
python cli.py load_archived_murs (upload all archived mur docs)
python cli.py load_archived_murs <mur_no> (upload single archived murs doc)
ex: python cli.py load_archived_murs 400
Test on browser: http://localhost:9200/archived_murs/_doc/mur_400



7) Upload rulemakings (rulemakings.py)
python cli.py load_rulemakings (upload all rulemakings docs)
python cli.py load_rulemakings <rm_no> (upload single rulemaking doc)
ex: python cli.py load_rulemakings 2021-01
Test on browser:



8)Show the type of analyzer set on an index: http://localhost:9200/<index_name>/_settings
ex: http://localhost:9200/case_index/_settings
ex: http://localhost:9200/ao_index/_settings
ex: http://localhost:9200/arch_mur_index/_settings
ex: http://localhost:9200/rm_index/_settings

7. Test endpoints

Start server: ./cli.py runserver
1)Endpoint path: /legal/search/ (class: UniversalSearch)
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

Test search document keyword:
http://127.0.0.1:5000/v1/legal/search/?q=house&type=advisory_opinions
http://127.0.0.1:5000/v1/legal/search/?q=house&type=murs
http://127.0.0.1:5000/v1/legal/search/?q=action&type=adrs
http://127.0.0.1:5000/v1/legal/search/?q=house&type=admin_fines
http://127.0.0.1:5000/v1/legal/search/?q=house&type=regulations
http://127.0.0.1:5000/v1/legal/search/?q=house&type=statutes
http://127.0.0.1:5000/v1/legal/search/?type=murs&q=peruse



2)Endpoint path: /legal/docs/<doc_type>/<no> (class: GetLegalDocument)
Test urls:
http://127.0.0.1:5000/v1/legal/docs/advisory_opinions/2020-05
http://127.0.0.1:5000/v1/legal/docs/murs/7212
http://127.0.0.1:5000/v1/legal/docs/murs/179
http://127.0.0.1:5000/v1/legal/docs/adrs/008
http://127.0.0.1:5000/v1/legal/docs/admin_fines/3314


3)Endpoint path: /rulemaking/search/ (class: RulemakingSearch)
http://127.0.0.1:5000/v1/rulemaking/search/
http://127.0.0.1:5000/v1/rulemaking/search/?rm_no=2024-10

Clone this wiki locally