Home  >  Q&A  >  body text

Laravel's package based on Elasticsearch - Elasticquent, the setting problem of using ik word segmentation

Use Laravel's Elasticsearch-based package (https://github.com/elasticquent/Elasticquent#indexes-and-mapping),

question:

1. When the following configuration uses ik word segmentation, how should it be set?
2. What are the concepts and functions of analysis, filter, and analyzer in the following code?

    protected $indexSettings = [
        'analysis' => [
            'char_filter' => [
                'replace' => [
                    'type' => 'mapping',
                    'mappings' => [
                        '&=> and '
                    ],
                ],
            ],
            'filter' => [
                'word_delimiter' => [
                    'type' => 'word_delimiter',
                    'split_on_numerics' => false,
                    'split_on_case_change' => true,
                    'generate_word_parts' => true,
                    'generate_number_parts' => true,
                    'catenate_all' => true,
                    'preserve_original' => true,
                    'catenate_numbers' => true,
                ]
            ],
            'analyzer' => [
                'default' => [
                    'type' => 'custom',
                    'char_filter' => [
                        'html_strip',
                        'replace',
                    ],
                    'tokenizer' => 'whitespace',
                    'filter' => [
                        'lowercase',
                        'word_delimiter',
                    ],
                ],
            ],
        ],
    ];
PHP中文网PHP中文网2736 days ago720

reply all(1)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 16:54:35

    Analysis, filter, analyzer, plus Chinese word segmentation and pinyin, this is already a huge amount of knowledge.
    Why don’t you start from the manual? Although I have just come into contact with elastic, I have spent a lot of time studying the manual.
    After all, this thing is huge and not so easy to get started

    Chinese manual (version 2.x): http://es.xiaoleilu.com
    Official manual: https://www.elastic.co/guide/...

    After reading the Chinese manual, I slowly started to read the official manual, and gradually gained some understanding of the above analyzers.

    reply
    0
  • Cancelreply