0

我在我的 Symfony 项目中运行 ONGR ElasticSearchBundle(以前我只使用 ES-PHP 客户端)。我将使用公司名称和描述搜索现有索引,索引名称是公司。它看起来是这样的:

"mappings": {
        "_doc": {
            "properties": {
                "id": {"type": "long"},
                "entityid": {"type": "long"},
                "entityname": {"type": "keyword"},
                "name": {"type": "text"},
                "street": {"type": "text"},
                "city": {"type": "text"},
                "zip": {"type": "long"},
                "ziptext": {"type": "keyword"},
                "regionisocode": {"type": "keyword"},
                "desc": {"type": "text"},
                "branch": {"type": "text"},
                "branchid": {"type": "long"},
                "foundingyear": {"type": "date"}

            }
        }
    }

文档类看起来是这样的:

/**
 * Company
 *
 * @ES\Document()
 */
class Company
{
    /**
     * @var string
     *
     * @ES\Property(type="long", options={"index"="not_analyzed"})
     */
    private $id;

    /**
     * @var string
     *
     * @ES\Property(type="long", options={"index"="not_analyzed"})
     */
    private $entityid;

    /**
     * @var string
     *
     * @ES\Property(type="keyword", options={"index"="not_analyzed"})
     */
    private $entityname;
...

当我将注释更改为:

/**
 * Company
 *
 * @ES\Document(type="_doc")
 */

然后搜索运行正常,但我无法执行任何作曲家命令,因为我收到此错误: 我在GitHub 上[RuntimeException]An error occurred when executing the "'cache:clear --no-warmup'" command:[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundExcepton] The service "company_search_service" has a dependency on a non-existent service "es.manager.default.company". 的 Bundle 中发现了一个问题,但它已经过去了四年多,并且已经关闭。

没有@ES\Document(type="_doc")注释我无法访问索引。也许有人有建议?先感谢您

我正在使用 Symfony 2.8 和 ONGR/Elastic Bundle 5.2.4

4

1 回答 1

0

我不知道它是否仍然相关,但失败的服务是您文档的存储库服务。它失败了,因为您可能在某个地方需要它。存储库服务名称是通过将管理器服务名称 ( es.manager.default) 附加到类型名称(默认情况下是小写的文档类名称,在您的情况下为 - company)来动态生成的,因此是 - es.manager.default.company。当您添加不同的类型名称(_doc在这种情况下)时,您的存储库名称更改为,我想,es.manager.default._doc. 您可以检查这一点并更改您的服务要求,但老实说,我不鼓励使用_doc作为类型名称。

于 2019-10-08T12:01:22.140 回答