ES Common query command

  • View Index

`curl '10.95.32.34:9200/_cat/indices?v'`
  • Creating an index

    curl -XPUT  '10.95.32.34:9200/customer-test?pretty'
  • Insert data:

    curl -XPUT '10.95.32.34:9200/customer-test/employee/2?pretty' -d '{"name": "John smart"}'
    curl -XPUT '10.95.32.34:9200/customer-test/employee/1' -d '{"first_name":"John","last_name":"Smith","age":25,"about":"Ilovetogorockclimbing","interests":["sports","music"]}'
  • View data:

    curl -XPOST '10.95.32.34:9200/customer-test/_search?pretty'
  • View Health:

    [root@server02 ~]# curl  -sXGET 'http://localhost:9200/_cluster/health?pretty'
    {
    "cluster_name" : "es",
    "status" : "green",
    "timed_out" : false,
    "number_of_nodes" : 9,
    "number_of_data_nodes" : 9,
    "active_primary_shards" : 129,
    "active_shards" : 258,
    "relocating_shards" : 0,
    "initializing_shards" : 0,
    "unassigned_shards" : 0,
    "delayed_unassigned_shards" : 0,
    "number_of_pending_tasks" : 0,
    "number_of_in_flight_fetch" : 0,
    "task_max_waiting_in_queue_millis" : 0,
    "active_shards_percent_as_number" : 100.0
    }
  • Find the index unfragmented

    curl -s "http://localhost:9200/_cat/shards" | grep UNASSIGNED
  • Delete the index:

    curl -XDELETE 'http://localhost:9200/noah_flow_file_20190625'
  • Find unassigned index
    curl  -s 'http://localhost:9200/_cat/shards' | grep UNASSIGNED | awk '{print $1}' | sort | uniq

Guess you like

Origin blog.51cto.com/fengyunshan911/2416105