ElasticSearch of index data

1) Create an index

PUT / {} Index Name

{
   " Settings " : {
     " number_of_shards " : 5 , // number of slices in each of the main index, the default value is 5. This configuration can not be changed after the index creation.
    " Number_of_replicas " : the number of copies for each master slice 1 // default value is 1. For the index database activity, this configuration can be modified at any time 
  } 
}

  Modification method index settings:

PUT / {Index Name} / _ settings

{
   " Settings " : {
     " number_of_replicas " : 1  // number of copies for each master slice, the default value is 1. For the index database activity, this configuration can be modified at any time 
  } 
}

 

2) Create a mapping

POST / {Index Name} / {type name} / _ Mapping {

"{type名称}": {
        "properties": {
            "id": {
                "type": "integer"
            },
            "cid": {
                "type": "integer"
            },
            "title": {
                "type": "text"
            },
            "info": {
                "type": "text"
            },
            "eudid": {
                "type": "integer"
            },
            "gender": {
                "type": "integer"
            },
            "years": {
                "type": "integer"
            },
            "company_title": {
                "type": "text"
            },
            "update_time": {
                "type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
            }
        }
    }
}

View Mapping 

GET / {Index Name} / {type name} / _ mapping

 

4) Add Data

The PUT / Index Name} {/} {type name / id} {data

{
    "id": "401",
    "cid": "7",
    "title": "会计",
    "info": "一年以上经验",
    "eduid": "1",
    "gender": "0",
    "years": "1",
    "update_time": "2018-07-28 09:57:27",
    "company_title": "天睛事务所"
}

 

5) Search

POST / {Index Name} / {type name} / _ search

{
       // search condition   
}

Single data query    the GET / Index Name} {/} {type name / id} {data

Remove the DELETE single data / Index Name} {/} {type name / id} {data

Modifying the POST single data / Index Name} {/} {type name / id} {data

{
    "cid": "7",
    "title": "会计",
    "info": "一年以上经验",
    "eduid": "1",
    "gender": "0",
    "years": "1",
    "update_time": "09:57:27 2018-07-28 " ,
     " COMPANY_TITLE " : " days eye firm " 
}

 

Guess you like

Origin www.cnblogs.com/itcaigen/p/12642425.html