作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的收藏如下:
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "10000",
"_score" : 1.0,
"_source" : {
"user_id" : 12,
"index_date" : {
"date" : "2018-02-06 14:25:49.816952",
"timezone_type" : 3,
"timezone" : "UTC"
},
"rating" : null,
"orders" : [
{
"hour" : "08",
"count" : 1
},
{
"hour" : "10",
"count" : 1
}
],
"products" : [
{
"p_id" : 970111,
"count" : 4
},
{
"p_id" : 1280811,
"count" : 1
},
]
}
},
$query = new Query\Nested();
$query->setPath('orders');
$term = new Term();
$term->setTerm('orders.hour', $order->getCreatedAt()->format('H'));
$query->setQuery($term);
dump($finder->find($query));die;
[Elastica\Exception\ResponseException]
failed to create query: {
"nested" : {
"query" : {
"term" : {
"orders.hour" : {
"value" : "12",
"boost" : 1.0
}
}
},
"path" : "orders",
"ignore_unmapped" : false,
"score_mode" : "avg",
"boost" : 1.0
}
} [index: test_index] [reason: all shards failed]
最佳答案
您的文档看起来不像嵌套查询。
我假设finder是您的repository manager
,它被定义为orders
存储库,您的代码应如下所示
$finder = $this->get('fos_elastica.repository_manager')->getRepository('YourBundle:order');
$boolquery = new Query\BoolQuery();
$term = new Query\Term();
$term->setTerm('hour', $order->getCreatedAt()->format('H'));
$boolquery->addMust($term);
$finder->find($boolquery);
关于php - FOSElastica嵌套查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48646929/
我用他们的Docker镜像安装了ElasticSearch 6,并且一切正常。 然后,我像文档中所述安装并配置了FOSElastica。 这是fos_elastica的以下配置 fos_elastic
我已经配置了 FOSElasticaBundle 如下: fos_elastica: clients: default: { host: %elasticsearch_host
你好,我有一个问题.. 我有我的 elastica 存储库 namespace XX\xxx; use FOS\ElasticaBundle\Repository; class TestReposit
我试图通过全局索引搜索返回突出显示 FOSElastica Bundle . 我的配置(yml 文件)中有一个全局索引查找器: fos_elastica: clients: default
我将带有 Composer 的 FOSElastica 3.0 安装到我的 Symfony 项目中。这是我的配置: fos_elastica: clients: default
我是一名优秀的程序员,十分优秀!