I want to use Elasticsearch for blog posts to do the site search, backstage with PHP.
The full fields of the article table articles are as follows:
id title content user_id created_at updated_at
Now I want to create an index of three fields for the title field, the Content field, and the Updated_at field of the article table.
Here is my reference to the official document of the elasticsearch-php client to create an index blog and create a type article demo, participle used to IK participle.
Some of these options are not clear what the meaning, the specific problem in the following code (there are 4), please God to help answer, thank you.
Official Document Link: https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_index_management_operations.html# _create_an_index_advanced_example
$params = [' Index ' = ' blog ', ' body ' = = [' Settings ' = [ ' Number_of_shards ' = 1, ' Number_of_replicas ' + 0, ' analysis ' [' Filter ' = + [///1, two shingle here should be changed to article? ' Shingle ' = [' type ' = ' shingle '] ],//2, what does the contents of Char_filter mean? including Pre_negs and Post_negs. ' Char_filter ' = [' pre_negs ' = [' type ' = ' = ' Pattern_r Eplace ', ' pattern ' = ' (\\w+) \\s+ (? I:never|no|nothing|nowhere|noone|none|not|havent|has nt|hadnt|cant|couldnt|shouldnt|wont|wouldnt|dont|doesnt|didnt|isnt|arent|aint)) \\b ', ' Repla Cement ' = ' ~$1 ' ], ' post_negs ' = [' type ' = ' pattern_replace ', ' Pattern ' = ' \\b ' (? I:never|no|nothing|nowhere|noone|none|not|havent|hasnt|hadnt|cant|cou Ldnt|shouldnt|wont|wouldnt|dont|doesnt|didnt|isnt|arent|aint) \\s+ (\\w+) ', ' Replacement ' =& Gt ' $ ~$2 '],//3, Analyzer's content needs to be modified? ' Analyzer ' and ' [' blog ' = [' type ' = ' + ' cus Tom ', ' tokenizer ' = ' standard ', ' filter ' and ' = ' Lowerca Se ', ' stop ', ' Kstem ']]], ' Mappings ' = [' article ' and ' [' _all ' = [ "Analyzer" => "Ik_max_word", "search_analyzer" = "Ik_max_word", "Term_vector" = "No", "store" = "false"], ' properties ' = = [' title ' = = ' type ' = ' string ', ' Store ' = ' no ', ' term_vector ' = ' with_positions_offsets ', ' Analyzer ' = ' ik_max_word ', ' search_analyzer ' = ' Ik_max_word ', ' Include_in_all ' = ' true ', ' boost ' = 9 ], ' content ' = = [' Type ' = ' string ', ' Store ' = ' no ', ' term_vector ' = ' with_positions_offsets ', ' Analyzer ' = ' ik_max_word ', ' search_analyzer ' = ' Ik_max_word ', ' Include_in_all ' = ' true ', ' boost ' = 8 ],//4, time is only used in the search when the sort used, the following options how to fill? ' Updated_at ' = [' type ' = ' = ', ' store ' = = ', ' Term_vector ' = ', ' analyzer ' ' Search_analyzer ' = ', ' include_in_all ' and ', ' ' Boost ' = []]] ] ]; $client->indices ()->create ($params);
Reply content:
I want to use Elasticsearch for blog posts to do the site search, backstage with PHP.
The full fields of the article table articles are as follows:
id title content user_id created_at updated_at
Now I want to create an index of three fields for the title field, the Content field, and the Updated_at field of the article table.
Here is my reference to the official document of the elasticsearch-php client to create an index blog and create a type article demo, participle used to IK participle.
Some of these options are not clear what the meaning, the specific problem in the following code (there are 4), please God to help answer, thank you.
Official Document Link: https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_index_management_operations.html# _create_an_index_advanced_example
$params = [' Index ' = ' blog ', ' body ' = = [' Settings ' = [ ' Number_of_shards ' = 1, ' Number_of_replicas ' + 0, ' analysis ' [' Filter ' = + [///1, two shingle here should be changed to article? ' Shingle ' = [' type ' = ' shingle '] ],//2, what does the contents of Char_filter mean? including Pre_negs and Post_negs. ' Char_filter ' = [' pre_negs ' = [' type ' = ' = ' Pattern_r Eplace ', ' pattern ' = ' (\\w+) \\s+ (? I:never|no|nothing|nowhere|noone|none|not|havent|has nt|hadnt|cant|couldnt|shouldnt|wont|wouldnt|dont|doesnt|didnt|isnt|arent|aint)) \\b ', ' Repla Cement ' = ' ~$1 ' ], ' post_negs ' = [' type ' = ' pattern_replace ', ' Pattern ' = ' \\b ' (? I:never|no|nothing|nowhere|noone|none|not|havent|hasnt|hadnt|cant|cou Ldnt|shouldnt|wont|wouldnt|dont|doesnt|didnt|isnt|arent|aint) \\s+ (\\w+) ', ' Replacement ' =& Gt ' $ ~$2 '],//3, Analyzer's content needs to be modified? ' Analyzer ' and ' [' blog ' = [' type ' = ' + ' cus Tom ', ' tokenizer ' = ' standard ', ' filter ' and ' = ' Lowerca Se ', ' stop ', ' Kstem ']]], ' Mappings ' = [' article ' and ' [' _all ' = [ "Analyzer" => "Ik_max_word", "search_analyzer" = "Ik_max_word", "Term_vector" = "No", "store" = "false"], ' properties ' = = [' title ' = = ' type ' = ' string ', ' Store ' = ' no ', ' term_vector ' = ' with_positions_offsets ', ' Analyzer ' = ' ik_max_word ', ' search_analyzer ' = ' Ik_max_word ', ' Include_in_all ' = ' true ', ' boost ' = 9 ], ' content ' = = [' Type ' = ' string ', ' Store ' = ' no ', ' term_vector ' = ' with_positions_offsets ', ' Analyzer ' = ' ik_max_word ', ' search_analyzer ' = ' Ik_max_word ', ' Include_in_all ' = ' true ', ' boost ' = 8 ],//4, time is only used in the search when the sort used, the following options how to fill? ' Updated_at ' = [' type ' = ' = ', ' store ' = = ', ' Term_vector ' = ', ' analyzer ' ' Search_analyzer ' = ', ' include_in_all ' and ', ' ' Boost ' = []]] ] ]; $client->indices ()->create ($params);