oat-sa / lib-tao-elasticsearch

使用Elasticsearch在Tao中进行搜索的库


README

这个库现在不应再使用,因为它与Tao扩展紧密耦合,其代码无法用于其他应用程序。

请参考高级搜索扩展,当实现与TAO平台搜索相关的Elasticsearch集成时。

No Maintenance Intended

lib-tao-elasticsearch

Elastic Search搜索引擎

安装

基于cli脚本的安装方法
sudo php vendor/oat-sa/lib-tao-elasticsearch/bin/activateElasticSearch.php <pathToTaoRoot> <host> <port> <login> <password>
  • pathToTaoRoot 是您的Tao根目录
  • host 是您的Elasticsearch环境的主机。默认为localhost
  • port 是您的Elasticsearch环境的端口号。默认为9200
  • login 是您的Elasticsearch环境的登录名。可选属性。
  • password 是您的Elasticsearch环境的密码。可选属性。
基于种子文件的安装方法

以下内容应包含在种子文件中,并描述了一个引擎、连接字符串、服务配置和回退

        "tao": {
          "search": {
            "type": "configurableService",
            "class": "oat\\tao\\elasticsearch\\ElasticSearch",
            "options": {
              "hosts": [
                {
                  "host": "elasticsearch",
                  "port": 9200
                }
              ],
              "settings": {
                "analysis": {
                  "filter": {
                    "autocomplete_filter": {
                      "type": "edge_ngram",
                      "min_gram": 1,
                      "max_gram": 100
                    }
                  },
                  "analyzer": {
                    "autocomplete": {
                      "type": "custom",
                      "tokenizer": "standard",
                      "filter": [
                        "lowercase",
                        "autocomplete_filter"
                      ]
                    }
                  }
                }
              },
              "oat\\tao\\model\\search\\strategy\\GenerisSearch": {
                "type": "configurableService",
                "class": "oat\\tao\\model\\search\\strategy\\GenerisSearch"
              }
            }
          }
        }

在安装阶段创建适当的索引结构时,可以使用以下内容,其中 indexFiles 包含声明的绝对路径,示例在此库中提供(@TODO 应解耦)

"postInstall": [
    {
      "class": "\\oat\\tao\\elasticsearch\\Action\\IndexCreator",
      "params": [
        "--indexFiles",
        "/var/www/html/vendor/oat-sa/lib-tao-elasticsearch/config/index.conf.php"
      ]
    }
  ]

设置

Add your elasticsearch host to the config/tao/search.conf.php like 
    'hosts' => array(
        'https://:9200'
    ),
Add you castom settings, filters or analysis

 'settings' => array(
        'analysis' => array(
            'filter' => array(
                'autocomplete_filter' => array(
                    'type' => 'edge_ngram',
                    'min_gram' => 1,
                    'max_gram' => 100
                )
            ),
            'analyzer' => array(
                'autocomplete' => array(
                    'type' => 'custom',
                    'tokenizer' => 'standard',
                    'filter' => array(
                        'lowercase',
                        'autocomplete_filter'
                    )
                )
            )
        )
    ),
 'isMap' => true

完成此步骤后,您需要将文档填充到索引中。为此,您必须运行

$ bash tao/scripts/tools/index/IndexPopulator.sh <TAO_PLATFORM_ROOT>

此脚本将索引TAO平台上的所有资源以供Elasticsearch使用。