首页 >

elasticsearch创建索引时的一些选项问题

后端开发|php教程elasticsearch创建索引时的一些选项问题
elasticsearch,php
后端开发-php教程
我想用elasticsearch为博客的文章做站内搜索,后台用的php。
漂亮权限后台框架源码,vscode爆炸效果,ubuntu avnet,tomcat访问极限,sqlite3查表结构,zepto瀑布流插件,现在前端流行哪个框架,株洲微信秋天的爬虫,php环境搭建图片,无锡seo推广介绍,网站点评插件,鼠标缩放网页,模版与模板的区别lzw
文章表articles的全部字段如下:
营销推广平台源码,嵌入ubuntu教学视频,梦到灰色大爬虫,php fget(),seo怎样弄lzw
id     title     content     user_id    created_at     updated_at

现在我想为文章表的title字段、content字段、updated_at字段,共三个字段创建索引。

网站信息发布cms系统源码,pe里面装Ubuntu,nodejs能做爬虫吗,mip php推送,鄂州seo方法lzw
下面是我参照elasticsearch-php客户端的官方文档写的创建索引blog和创建类型article的demo,分词用到了ik分词。

其中有些选项不太清楚什么意思,具体问题在下面代码中(有4个),请大神帮解答一下,谢谢。

官方文档链接: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、这里的两个shingle应该改成article吗?            'shingle' => ['type' => 'shingle'            ]        ],        //2、char_filter里面内容表示什么意思?包括pre_negs和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+)','replacement' => '$1 ~$2'            ]        ],        //3、analyzer的内容需要怎么修改吗?        '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、时间只是用来在搜索的时候排序使用,下面的选项该怎么填写?            'updated_at' => ['type' => '','store' => '','term_vector' => '','analyzer' => '','search_analyzer' => '','include_in_all' => '','boost' =>             ]        ]    ]]            ]        ];        $client->indices()->create($params);

回复内容:

我想用elasticsearch为博客的文章做站内搜索,后台用的php。

文章表articles的全部字段如下:

id     title     content     user_id    created_at     updated_at

现在我想为文章表的title字段、content字段、updated_at字段,共三个字段创建索引。

下面是我参照elasticsearch-php客户端的官方文档写的创建索引blog和创建类型article的demo,分词用到了ik分词。

其中有些选项不太清楚什么意思,具体问题在下面代码中(有4个),请大神帮解答一下,谢谢。

官方文档链接: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、这里的两个shingle应该改成article吗?            'shingle' => ['type' => 'shingle'            ]        ],        //2、char_filter里面内容表示什么意思?包括pre_negs和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+)','replacement' => '$1 ~$2'            ]        ],        //3、analyzer的内容需要怎么修改吗?        '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、时间只是用来在搜索的时候排序使用,下面的选项该怎么填写?            'updated_at' => ['type' => '','store' => '','term_vector' => '','analyzer' => '','search_analyzer' => '','include_in_all' => '','boost' =>             ]        ]    ]]            ]        ];        $client->indices()->create($params);

elasticsearch创建索引时的一些选项问题
  • ElasticSearch使用
  • ElasticSearch使用 | ElasticSearch使用 ...

    elasticsearch创建索引时的一些选项问题
  • PHP Elasticsearch的基本使用方法
  • PHP Elasticsearch的基本使用方法 | PHP Elasticsearch的基本使用方法 ...

    elasticsearch创建索引时的一些选项问题
  • Elasticsearch做站内搜索,索引与mysql数据表同步问题
  • Elasticsearch做站内搜索,索引与mysql数据表同步问题 | Elasticsearch做站内搜索,索引与mysql数据表同步问题 ...