0

我在我的 Symfony 项目中安装了 ONGR ElasticSearchBundle。要使用公司名称和描述搜索索引,索引名称是公司。它看起来是这样的:

 "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;
...

到目前为止,这似乎有效。与 ElasicSearch 主机的连接正常,但即使我执行 MatchAllQuery() 我也没有得到搜索结果,我认为这是一个映射问题?Mayby有人有提示吗?

真挚地

4

1 回答 1

0

对您正在使用的工具(在 ES 旁边)没有任何经验,但是您实际上是否索引/插入了任何文档?

如果你有 ES 在本地运行,试试:localhost:9200/companies/_search验证是否有任何文档以及索引是否已经真正创建。

您是否遵循了这些步骤?此外,您还可以在此处找到有关索引数据的更多信息。

快乐编码!:D

于 2019-06-06T15:15:27.523 回答