aurora1625
1/20/2020 - 1:50 AM

elastic search

ElasticSearch Python script

## List all the index 
curl http://localhost:9200/_aliases?pretty=true

## create index with analyzer
# https://stackoverflow.com/a/21510876
client.indices.create(
    index=index,
    body={
      'settings': {
        # just one shard, no replicas for testing
        'number_of_shards': 1,
        'number_of_replicas': 0,

        # custom analyzer for analyzing file paths
        'analysis': {
          'analyzer': {
            'file_path': {
              'type': 'custom',
              'tokenizer': 'path_hierarchy',
              'filter': ['lowercase']
            }
          }
        }
      }
    },
    # Will ignore 400 errors, remove to ensure you're prompted
    ignore=400
)