ride/app-orm-elastic

Ride ORM 的 Elasticsearch 集成。

1.1.0 2017-02-08 10:39 UTC

This package is auto-updated.

Last update: 2024-09-21 19:27:03 UTC


README

本模块将 Elasticsearch 集成到 ORM 中。

要启用模型上的 Elastic,请将 behaviour.elastic 属性添加到模型选项中。将其设置为 Elasticsearch 服务器中数据的 index/type,例如 geo/locations。

当此行为启用时,将在您的入口类中生成一个名为 getElasticDocument 的方法。此方法将在 ORM 和 Elastic 之间进行转换。

Elastic 的映射基于您的模型定义。您可以通过将 elastic.omit 选项添加到字段中来跳过字段。

您需要使用 Elastic ORM 命令行工具来定义映射和索引现有记录。每次进行操作(插入、更新或删除)时,索引都会自动更新。

注意:当您启用 json API 时,您可以添加 elastic 过滤器以通过 Elastic 进行搜索。

<model name="GeoLocation">
    <field name="path" type="string">
        <validation name="required"/>
    </field>
    <field name="parent" model="GeoLocation" relation="belongsTo">
        <option name="elastic.omit" value="true"/>
    </field>
    <field name="name" type="string" localized="true">
        <validation name="required"/>
    </field>

    <option name="behaviour.elastic" value="geo/locations"/>
    <option name="json.api" value="geo-locations"/>
    <option name="json.api.filters" value="query,exact,match,expression,elastic"/>
</model>

相关模块

安装

您可以使用 Composer 安装此应用程序。

composer require ride/app-orm-elastic