gpt4 book ai didi

symfony - 尝试按GeoDistance进行过滤时出现PartialShardFailureException(foselasticaBundle Symfony2)

转载 作者:行者123 更新时间:2023-12-03 00:25:35 27 4
gpt4 key购买 nike

几天以来,我的elastica查询不再起作用。我没有问题可以填充,如果我删除了GeoDistance部分,则请求已执行,并且得到结果。当前,在跟踪中,我收到以下消息:

    "message": "1",
"class": "Elastica\\Exception\\PartialShardFailureException",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/Applications/MAMP/htdocs/GTAB/what2days/api/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php",
"line": 150,
"args": []
}

这对我来说没有任何意义,所以我只不过做了 $shardsStatistics变量的var_export而已:
    array (
'total' => 6,
'successful' => 5,
'failed' => 1,
'failures' =>
array (
0 =>
array (
'index' => '.marvel-2014.09.16',
'shard' => 0,
'status' => 400,
'reason' => 'SearchParseException[[.marvel-2014.09.16][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"online":{"value":1}}}]}},"filter":{"bool":{"must":[{"geo_distance":{"distance":"100mi","location.latlon":{"lat":48.891773,"lon":2.3379156}}}]}}}}}},"size":"100"}]]]; nested: QueryParsingException[[.marvel-2014.09.16] failed to find geo_point field [location.latlon]]; ',
),
),
)

错误结束处为“无法找到geo_point字段[location.latlon]]”。我不知道为什么它不起作用,因为当我检查_mapping时,geo_point存在并且我没有对属性名称犯错。
    location: {
properties: {
latitude: {
type: "float",
store: true
},
latlon: {
type: "geo_point",
store: true,
lat_lon: true
},
longitude: {
type: "float",
store: true
}
}
},

这就是我设置fos_elastica的方式
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
search:
finder: ~
types:
mytype:
mappings:
title:
type: string
online:
type: integer
information: ~
location:
type: object
properties:
longitude:
type: float
latlon:
type: geo_point
lat_lon: true
boost: 10
persistence:
driver: orm
model: API\Rest\v1\MyBundle\Entity\MyEntity
provider: ~
listener: ~
finder: ~
repository: API\Rest\v1\MyBundle\Repository\MyRepository

当我使用由$ query-> getQuery()检索的查询值(请参阅以下查询)发出kopf请求时,我得到了正确的结果。
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"term": {
"online": {
"value": 1
}
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"geo_distance": {
"distance": "1mi",
"location.latlon": {
"lat": 48.891773,
"lon": 2.3379156
}
}
}
]
}
}
}
}
}

我不知道该怎么办。我使用的是3.0.*@alpha版本,现在正在尝试开发者主机。我希望有人能帮助我找出问题所在。

当我从Elastica / Response.php的 getData方法中进行var_export时,我遇到了我前面解释的故障,并且我也有1个命中(一个我想得到的)。

最佳答案

我终于找到了解决方案。

我必须添加一个index_name并将\Elastica\Search告诉addIndex('new_index')addType('specific type')
我以为搜索会自动获得正确的索引,因为我使用的是特定的存储库,但是我错了。

关于symfony - 尝试按GeoDistance进行过滤时出现PartialShardFailureException(foselasticaBundle Symfony2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25873928/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com