我的 elastica 类型的配置如下所示:
acme_article:
mappings:
title: {type:string, index_analyzer:acme_analyzer}
content: {type:string, index_analyzer:acme_analyzer}
slug: ~
media: {type:string, index_analyzer:acme_analyzer}
categories:
type: "object"
properties:
name: ~
id: ~
instance:
type: "object"
properties:
name: ~
created_by: ~
created_at: ~
我有扩展 FOS\ElasticaBundle\Repository 的 Repository 类,除了排序之外,一切都运行良好。
$query = new \Elastica\Query();
$query->setSort(array('created_at' => array('order' => 'desc')));
return $this->find($query);
得到一些不相关的结果,完全没有顺序。然后,我尝试在索引中添加模型 id 并尝试按 id 排序但也没有成功。