Skip to content

Latest commit

 

History

History
78 lines (66 loc) · 1.16 KB

README.md

File metadata and controls

78 lines (66 loc) · 1.16 KB

Search - dev environment

Setup API

pnpm install
pnpm dev

Setup ElasticSearch

docker-compose up -d

setup the schema (gets automatically applied at startup of the api)

curl -XPUT "http://localhost:9200/osm" -H 'Content-Type: application/json' -d'
{
  index: 'osm',
  settings: {
    max_ngram_diff: 20,
    analysis: {
      filter: {
        ngram_filter: {
          type: 'ngram',
          min_gram: 2,
          max_gram: 20,
        },
      },
      analyzer: {
        ngram_analyzer: {
          type: 'custom',
          tokenizer: 'standard',
          filter: ['lowercase', 'ngram_filter'],
        },
      },
    },
  },
  mappings: {
    properties: {
      name: {
        type: 'text',
        term_vector: 'yes',
        analyzer: 'ngram_analyzer',
        search_analyzer: 'standard',
      },
      location: {
        type: 'geo_point',
      },
    },
  },
}'

find all items

curl -XGET "http://localhost:9200/_search" -H 'Content-Type: application/json' -d'
{
  "query": {
    "match_all": {}
  }
}'

delete the index

curl -XDELETE "http://localhost:9200/osm"

or

./deleteIndex