elasticsearch,geolocation,elastica,Symfony,elasticsearch,Geolocation,Elastica" /> elasticsearch,geolocation,elastica,Symfony,elasticsearch,Geolocation,Elastica" />

尝试按地理距离过滤时出现部分硬故障异常(foselasticaBundle Symfony2)

尝试按地理距离过滤时出现部分硬故障异常(foselasticaBundle Symfony2),symfony,elasticsearch,geolocation,elastica,Symfony,elasticsearch,Geolocation,Elastica,有几天我的elastica查询不再工作了。我没有问题来填充,如果我删除了地理距离部分,请求就会被执行,我会得到结果。目前,在跟踪中,我收到以下消息: "message": "1", "class": "Elastica\\Exception\\PartialShardFailureException", "trace": [ { "namespace": "", "short_class": "",

有几天我的elastica查询不再工作了。我没有问题来填充,如果我删除了地理距离部分,请求就会被执行,我会得到结果。目前,在跟踪中,我收到以下消息:

    "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": []
        }
这对我来说没什么意义,所以我只是导出了
$shardstatistics
变量,得到:

    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]]; ',
            ),
        ),
    )
错误以“未能找到地理点字段[location.latlon]]”结束。我不知道为什么它不起作用,因为当我检查_映射时,geo_点存在,并且我没有在属性名称上出错

    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版本,现在我正在试用dev master。我希望有人能帮我找出哪里出了问题


当我在Elastica/Response.php的方法
getData
中进行var_导出时,我遇到了前面解释过的故障,还有1次命中(我希望得到的结果)。

我终于找到了解决方案

我必须添加一个索引名,并告诉
\Elastica\Search
addIndex('new\u index')
addType('specific type')

我以为搜索会自动获得正确的索引,因为我使用的是特定的存储库,但我错了