org.elasticsearch.index.query.QueryShardException: failed to find geo_point field [geo]错误原因

报错意思是   错误的找不到  geo_point 类型, 名字叫做  geo 的字段

先从我创建索引说起。

1:用插件创建个名为  amapaa的索引,里面的 mappings 都是为空的

 2:直接执行新增数据操作,系统会 自动(动态)帮我们执行mapping 对象和es索引之间的关系连接

@Data
@Document(indexName = "amap", type = "_doc", createIndex = false)
public class User {

    @Id
    private Long userId;

    @Field(store = true)
    private String userName;

    @Field(store = true)
    @GeoPointField
    private GeoPoint geo;

    @Field(store = true)
    private String place;


    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                ", geo='" + geo + '\'' +
                ", place='" + place + '\'' +
                '}';
    }
}

3:但是 geo_point 类型并不会映射正确 ,映射成了float 类型 

4:在查询的时候就会抛出异常,第一个异常信息有误导到,还以为分片出现问题。 但是第二个说的就比较清楚了,也是问题的解决关键

org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:293)
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:133)
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:254)
	at org.elasticsearch.action.search.InitialSearchPhase.onShardFailure(InitialSearchPhase.java:101)
	at org.elasticsearch.action.search.InitialSearchPhase.access$100(InitialSearchPhase.java:48)
	at org.elasticsearch.action.search.InitialSearchPhase$2.lambda$onFailure$1(InitialSearchPhase.java:222)
	at org.elasticsearch.action.search.InitialSearchPhase.maybeFork(InitialSearchPhase.java:176)
	at org.elasticsearch.action.search.InitialSearchPhase.access$000(InitialSearchPhase.java:48)
	at org.elasticsearch.action.search.InitialSearchPhase$2.onFailure(InitialSearchPhase.java:222)
	at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:51)
	at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:526)
	at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1068)
	at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1165)
	at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1149)
	at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:66)
	at org.elasticsearch.action.search.SearchTransportService$5$1.onFailure(SearchTransportService.java:356)
	at org.elasticsearch.search.SearchService$1.onFailure(SearchService.java:292)
	at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:286)
	at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:280)
	at org.elasticsearch.search.SearchService$3.doRun(SearchService.java:1019)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:723)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.elasticsearch.index.query.QueryShardException: failed to find geo_point field [geo]
	at org.elasticsearch.index.query.GeoDistanceQueryBuilder.doToQuery(GeoDistanceQueryBuilder.java:244)
	at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:98)
	at org.elasticsearch.index.query.QueryShardContext.lambda$toQuery$2(QueryShardContext.java:305)
	at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:317)
	at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:304)
	at org.elasticsearch.search.SearchService.parseSource(SearchService.java:724)
	at org.elasticsearch.search.SearchService.createContext(SearchService.java:575)
	at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:551)
	at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:298)
	at org.elasticsearch.search.SearchService.access$000(SearchService.java:115)
	at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:284)
	... 9 common frames omitted

 5:删除掉错误的索引,用请求的方式 重新创建,提前指定好  geo 字段为  geo_point 类型

{
    "mappings": {
        "_doc": {
            "properties": {
                "geo": {
                    "type": "geo_point"
                }
            }
        }
    }
}

6: 重新增加一条数据测试,      其他字段动态映射进去, geo_point 类型在我们创建索引提前指定没有覆盖。   问题解决

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值