Some options during index creation of elasticsearch

Source: Internet
Author: User
I want to use elasticsearch to perform intra-site search for blog articles and use php in the background. All the fields in article table articles are as follows: {code...} now I want to create an index for the title field, content field, and updated_at field in the article table. The following is my reference to elastics... I want to use elasticsearch for blog posts for intra-site search, using php in the background.

All the fields in the article table articles are as follows:

id     title     content     user_id    created_at     updated_at

Now I want to create an index for the title field, content field, and updated_at field in the document table.

The following is a demo of creating an index blog and creating an article by referring to the official documents of the elasticsearch-php client. ik word segmentation is used for word segmentation.

Some of the options are not clear. the specific questions are in the code below (4). please help me solve them. 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, 'analytic' => ['filter' => [// 1. Should the two shingle values be changed to article? 'Shingle' => ['type' => 'shingle'], // 2. what does the content in char_filter mean? Including pre_negs and post_negs. 'Char _ filter' => ['pre _ negs '=> ['type' => 'pattern_replace', 'pattern' => '(\ w +) \ s + ((? I: never | no | nothing | nowhere | noone | none | not | havent | hasnt | hadnt | cant | couldnt | shouldnt | wont | wouldnt | dont | doesnt | didnt | isnt | arent | aint )) \ B ', 'replacement' => '~ $1 $2 '], 'post _ negs' => ['type' => 'pattern_replace ', 'pattern' =>' \ B ((? I: never | no | nothing | nowhere | noone | none | not | havent | hasnt | hadnt | cant | couldnt | shouldnt | wont | wouldnt | dont | doesnt | didnt | isnt | arent | aint )) \ s + (\ w +) ', 'replace' => '$1 ~ $2 '], // 3. how do I modify the analyzer content? 'Analyzer '=> ['blog' => ['type' => 'custom', 'tokenizer '=> 'standard', 'filter' => ['lowercase ', 'STOP', 'kstem '], 'mappings '=> ['article' => ["_ 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. the time is only used for sorting during search. how can I fill in the following options? 'Updated _ at' => ['type' => '', 'store' =>'', 'term _ vector '=> '', 'analyzer '=> '', 'search _ analyzer' =>'', 'include _ in_all '=> '', 'boost' =>]; $ client-> indices ()-> create ($ params );

Reply content:

I want to use elasticsearch to perform intra-site search for blog articles and use php in the background.

All the fields in the article table articles are as follows:

id     title     content     user_id    created_at     updated_at

Now I want to create an index for the title field, content field, and updated_at field in the document table.

The following is a demo of creating an index blog and creating an article by referring to the official documents of the elasticsearch-php client. ik word segmentation is used for word segmentation.

Some of the options are not clear. the specific questions are in the code below (4). please help me solve them. 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, 'analytic' => ['filter' => [// 1. Should the two shingle values be changed to article? 'Shingle' => ['type' => 'shingle'], // 2. what does the content in char_filter mean? Including pre_negs and post_negs. 'Char _ filter' => ['pre _ negs '=> ['type' => 'pattern_replace', 'pattern' => '(\ w +) \ s + ((? I: never | no | nothing | nowhere | noone | none | not | havent | hasnt | hadnt | cant | couldnt | shouldnt | wont | wouldnt | dont | doesnt | didnt | isnt | arent | aint )) \ B ', 'replacement' => '~ $1 $2 '], 'post _ negs' => ['type' => 'pattern_replace ', 'pattern' =>' \ B ((? I: never | no | nothing | nowhere | noone | none | not | havent | hasnt | hadnt | cant | couldnt | shouldnt | wont | wouldnt | dont | doesnt | didnt | isnt | arent | aint )) \ s + (\ w +) ', 'replace' => '$1 ~ $2 '], // 3. how do I modify the analyzer content? 'Analyzer '=> ['blog' => ['type' => 'custom', 'tokenizer '=> 'standard', 'filter' => ['lowercase ', 'STOP', 'kstem '], 'mappings '=> ['article' => ["_ 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. the time is only used for sorting during search. how can I fill in the following options? 'Updated _ at' => ['type' => '', 'store' =>'', 'term _ vector '=> '', 'analyzer '=> '', 'search _ analyzer' =>'', 'include _ in_all '=> '', 'boost' =>]; $ client-> indices ()-> create ($ params );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.