Relational DB -> Databases -> Tables -> Rows -> ColumnsElasticsearch -> Indices -> Types -> Documents -> Fields
public function createIndexMap()
{
$body['settings']=[
'index'=>['max_result_window'=>2000000],//最大长度
'number_of_shards'=>5, //主分片数量
'number_of_replicas'=>1,//从分片数量
'analysis'=>[ //定制化分析器
'tokenizer'=>[ //分词器
'standard_one_word_tokenizer'=>[
'type'=>'standard',
'max_token_length'=>1,
]
],
'filter'=>[ //分词过滤器
'edge_ngram_filter'=>[
'type'=>'edge_ngram',
'min_gram'=>1,
'max_gram'=>20,
],
"unit_synonym"=>[
"type"=>"synonym", //同义词
"synonyms"=>[
'ggt,滴',
'kg,公斤',
'μg,微克',
'iu,国际单位',
'u,单位',
'MEq,豪当量',
"mg, 毫克",
"ml,毫升",
'cm,厘米',
"g,克",
'l,升',
's,粒',
"0.05g,0.05克,50mg,50毫克=>50mg",
"0.1g,0.1克,100mg,100毫克=>100mg",
"0.125g,0.125克,125mg,125毫克=>125mg",
"0.15g,0.15克,150mg,150毫克=>150mg",
"0.2g,0.2克,200mg,200毫克=>200mg",
"0.25g,0.25克,250mg,250毫克=>250mg",
"0.3g,0.3克,300mg,300毫克=>300mg",
"0.35g,0.35克,350mg,350毫克=>250mg",
"0.4g,0.4克,400mg,400毫克=>400mg",
"0.45g,0.45克,450mg,450毫克=>450mg",
"0.5g,0.5克,500mg,500毫克=>500mg",
"0.55g,0.5克,550mg,550毫克=>550mg",
"0.6g,0.6克,600mg,600毫克=>600mg",
"0.65g,0.65克,650mg,650毫克=>650mg",
"0.7g,0.7克,700mg,700毫克=>700mg",
"0.75g,0.75克,750mg,750毫克=>750mg",
"0.8g,0.8克,800mg,800毫克=>800mg",
"0.85g,0.85克,850mg,850毫克=>850mg",
"0.9g,0.9克,900mg,900毫克=>900mg",
"0.95g,0.95克,950mg,950毫克=>950mg",
"1g,1克,1000mg,1000毫克=>1000mg",
]
],
'length_filter'=>[
'type'=>'length',
'min'=>2,
],
'pinyin_full_filter'=>[
"type"=>"pinyin",
"keep_separate_first_letter"=> false,
"keep_full_pinyin"=>true,
"keep_original" =>false,
"limit_first_letter_length" => 10,
"lowercase" =>true,
"remove_duplicated_term" =>true
],
'pinyin_first_filter'=>[
"type"=>"pinyin",
'keep_first_letter'=>true,
"keep_separate_first_letter"=> false,
"keep_full_pinyin"=>false,
"keep_original" =>false,
'keep_none_chinese'=>false,
"limit_first_letter_length" => 10,
"lowercase" =>true,
"remove_duplicated_term" =>true
],
],
'analyzer'=>[
'default'=>[
'tokenizer'=>'ik_max_word'
],
"pinyin_full_analyzer" => [
//custom代表自定义的分词器。默认为stardard
'type'=>'custom',
"tokenizer"=>"ik_smart",
"filter"=>["lowercase", "pinyin_full_filter","length_filter"],
],
"pinyin_first_analyzer" => [
'type'=>'custom',
"tokenizer"=>"keyword",
"filter"=>["lowercase", "pinyin_first_filter",'edge_ngram_filter',"length_filter"],
],
"ik_analyzer" => [
'type'=>'custom',
"tokenizer"=>"standard",
"filter"=>["lowercase"],
],
'stand_one_word_analyzer'=>[
'type'=>'custom',
"tokenizer"=>"standard",
"filter"=>["lowercase",'unit_synonym'],
],
"comma"=> [
"type"=>"pattern",
"pattern"=>","
]
]
]
];
$body['mappings']['_source']['enabled']=true;
// $body['mappings']['_routing'] = [
// 'required' => true,
//// 'path' => '_routing'
// ];
$body['mappings']['properties']=[
'product_relation' => [
'type' => 'join',
'relations' => [
'productinfo' => 'productquantity',
]
],
'product_id' => [
'type' => 'long'
],
'quantity'=>[
'type'=>'long',
],
'has_quantity'=>[
'type'=>'short',
],
'virtual_sales'=>[
'type'=>'long',
],
'create_time'=>[
'type'=>'date',
],
'line_status'=>[
'type'=>'short',
],
'store_id'=>[
'type'=>'long',
],
'real_price'=>[
'type'=>'double',
],
'store_price'=>[
'type'=>'double',
],
'is_cross_border'=>[
'type'=>'short',
],
'is_online_payment'=>[
'type'=>'short',
],
'dtp_status'=>[
'type'=>'short',
],
'is_vip_product' => [
'type' => 'short'
],
'vip_product_price' => [
'type' => 'double'
],
'vip_product_is_plus_vip_product' => [
'type' => 'short'
],
'vip_product_plus_vip_price' => [
'type' => 'double'
],
'vip_product_unopen_is_show_price' => [
'type' => 'short'
],
'vip_product_is_choicenes' => [
'type' => 'short'
],
'brand_id'=>[
'type'=>'long',
],
'category_id'=>[
'type'=>'long',
],
'category_id_2'=>[
'type'=>'long',
],
'category_id_3'=>[
'type'=>'long',
],
'head_pic'=>[
'type'=>'keyword',
],
'is_chufang'=>[
'type'=>'short',
],
'product_title'=>[
'type'=>'keyword',
'fields'=>[
'pinyin_full'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_full_analyzer"
],
'pinyin_letter'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_first_analyzer"
],
'text'=>[
"type"=>"text",
"analyzer"=>"ik_analyzer"
]
]
],
'product_tags_id'=>[
'type'=>'text',
"analyzer"=>"comma",
"search_analyzer"=> "comma"
],
'product_tags'=>[
'type'=>'keyword',
'fields'=>[
'pinyin_full'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_full_analyzer"
],
'pinyin_letter'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_first_analyzer"
],
'text'=>[
"type"=>"text",
"analyzer"=>"ik_analyzer"
]
]
],
'product_tags_multi' => [
'type'=>'keyword',
'fields'=>[
'pinyin_full'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_full_analyzer"
],
'pinyin_letter'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_first_analyzer"
],
'text'=>[
"type"=>"text",
"analyzer"=>"ik_analyzer"
]
]
],
'cn_comm_name'=>[
'type'=>'keyword',
'fields'=>[
'pinyin_full'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_full_analyzer"
],
'pinyin_letter'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_first_analyzer"
],
'text'=>[
"type"=>"text",
"analyzer"=>"ik_analyzer"
],
'doctor_search'=>[
'type'=>'text',
'analyzer'=>'stand_one_word_analyzer',
'position_increment_gap'=>'100'
]
]
],
'product_name'=>[
'type'=>'keyword',
'fields'=>[
'pinyin_full'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_full_analyzer"
],
'pinyin_letter'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_first_analyzer"
],
'text'=>[
"type"=>"text",
"analyzer"=>"ik_analyzer"
],
'doctor_search'=>[
'type'=>'text',
'analyzer'=>'stand_one_word_analyzer',
'position_increment_gap'=>'100'
]
]
],
'dosage_from'=>[
'type'=>'keyword',
'fields'=>[
'doctor_search'=>
[
'type'=>'text',
'analyzer'=>'stand_one_word_analyzer',
'position_increment_gap'=>'100'
]
]
],
'format'=>[
'type'=>'keyword',
'fields'=>[
'doctor_search'=>
[
'type'=>'text',
'analyzer'=>'stand_one_word_analyzer',
'position_increment_gap'=>'100'
]
]
],
'business_name'=>[
'type'=>'keyword',
'fields'=>[
'doctor_search'=>
[
'type'=>'text',
'analyzer'=>'stand_one_word_analyzer',
'position_increment_gap'=>'100'
],
'pinyin_letter'=>[
"type"=>"text",
"term_vector"=>"with_positions_offsets",
"analyzer"=>"pinyin_first_analyzer"
],
'text'=>[
"type"=>"text",
"analyzer"=>"ik_analyzer"
],
]
],
'product_code'=>[
'type'=>'keyword',
],
'pf_unique_code'=>[
'type'=>'keyword',
],
'indication'=>[
'type'=>'keyword',
'fields'=>[
'text'=>[
"type"=>"text",
"analyzer"=>"ik_analyzer"
]
]
]
];
$this->createMapping($body);
}
