承接 lazar/elastic 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lazar/elastic

最新稳定版本:v0.07

Composer 安装命令:

composer require lazar/elastic

包简介

elasticsearch for news portals

README 文档

README

Installation:

If Front and CMS are separate projects, the installation procedure is as follows.

  1. composer require lazar/elastic (on both projects)
  2. php artisan vendor:publish --tag=config --provider="News\Elasticsearch\ElasticsearchServiceProvider" (on both projects)
  3. Set up config/elasticsearch.php (on both projects)
  4. php artisan vendor:publish --tag=controller --provider="News\Elasticsearch\ElasticsearchServiceProvider" (front)
  5. php artisan vendor:publish --tag=commands --provider="News\Elasticsearch\ElasticsearchServiceProvider" (cms)
  6. Use Package :D

CMS

The console command to create the index is run manually. The console command for updating the index is started with the help of ArticleObserver, so that it "listens" to what is happening with the article. Depending on whether it is created, updated or deleted, it will start the corresponding method. In the config file, the "run_observer" key is set to "true" to enable the index to be updated. Also, if you want to enable search by tag, you can do so by setting the key "include_tags_in_search" to "true" in the config file.

Front

Adjust the config file depending on the config file from the CMS. Customize the view blade based on the data you get from the controller. If your portal is

Enabling Search for Serbian Special Characters

If your portal is in the Serbian language and you want to include special characters such as Č, Ć, Š, Ž, Đ in the search functionality, you need to add the following configuration to the index at the beginning of the index body:

        'settings' => [
            'analysis' => [
                'filter' => [
                    'serbian_folding' => [
                        'type' => 'asciifolding', // Converts diacritical characters
                        'preserve_original' => true
                    ]
                ],
                'analyzer' => [
                    'serbian_analyzer' => [
                        'type' => 'custom',
                        'tokenizer' => 'standard',
                        'filter' => ['lowercase', 'serbian_folding']
                    ]
                ]
            ]
        ],

For each field you want to search by, add 'analyzer' => 'serbian_analyzer'. For example, if you're searching by title, it would look like this:

        'heading' => [
            'type' => 'text',
            'analyzer' => 'serbian_analyzer'
        ],

This will ensure that Serbian diacritical characters are properly handled in the search functionality of your portal.

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-02-05