$params = [
'index' => 'products',
'body' => [
"properties" => [
"type" => ["type" => "keyword"],
"product_core" => ["type" => "text"],
"title" => ["type" => "text", "analyzer" => "ik_smart"],
"bar_code" => ["type" => "text"],
"category" => ["type" => "keyword"],
"category_path" => ["type" => "keyword"],
"status" => ["type" => "boolean"],
"audit_status" => ["type" => "integer"],
"shop_name" => ["type" => "text", "analyzer" => "ik_smart"],
"description" => ["type" => "text", "analyzer" => "ik_smart"],
"rating" => ["type" => "float"],
"sold_count" => ["type" => "integer"],
"review_count" => ["type" => "integer"],
"price" => ["type" => "scaled_float", "scaling_factor" => 100],
"image" => ["type" => "text"],
"skus" => [
"type" => "nested",
"properties" => [
"title" => ["type" => "text", "analyzer" => "ik_smart"],
"description" => ["type" => "text", "analyzer" => "ik_smart"],
"price" => ["type" => "scaled_float", "scaling_factor" => 100]
]
],
"properties" => [
"type" => "nested",
"properties" => [
"name" => ["type" => "keyword"],
"value" => ["type" => "keyword"]
]
]
]
]
];
// 创建一个简单的索引
try {
$response = app('es')->indices()->putMapping($params);
print_r($response);
} catch (\Exception $e) {
echo 'error: ' . $e->getMessage();
}