$client = Elasticsearch\ClientBuilder::create()

# ->setHosts(["localhost:9200"])

->setHosts(["101.37.85.163:9200"])

->setRetries(1)

->build();

 

//创建mapping

$mapParam = array(

'index' => 'checheng_index',

'body' =>[

'settings' => [

'number_of_shards' => 5,

'number_of_replicas' => 1

],

'mappings' =>[

'checheng_type' =>[

#'_source' => array(

# 'enable' => true

# ),

'properties' => array(

'id' => array(

'type' => 'integer',

#'analyzer' => 'not_analyzed'

),

'title'=>array(

'type' => 'string',

'analyzer' => 'ik'

),

'inputtime'=>array(

#'type' => 'date',

#'analyzer' => 'not_analyzed'

),

'description' => array(

'type' => 'string',

'analyzer'=> 'ik'

),

'content' => array(

'type' => 'string',

'analyzer'=> 'ik'

)

)

]

]

],

 

);

$response = $client -> indices() -> create($mapParam);