我有一个用于使用elasticsearch GeopointSpring引导应用程序。当我保存弹性索引并创建geoDistanceQuery时,我得到了QueryShardException[未能找到geo_point字段[customer]]异常。
我的文件;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.GeoPointField;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Getter
@Setter
@Document(indexName = "customer", replicas = 0, refreshInterval = "-1")
public class Customer {
@GeneratedValue(strategy= GenerationType.AUTO)
@Id
private String id;
private Integer cifNo;
private String userId;
private String name;
@GeoPointField
private GeoPoint geoPoint;
}
储存库;
@Repository
public interface CustomerRepository extends ElasticsearchRepository<Customer, String> { }
保存和获取方法;
import com.system.management.domain.entity.Customer;
import com.system.management.repository.CustomerRepository;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.query.GeoDistanceQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class LocationFinder {
@Autowired
public ElasticsearchOperations elasticsearchTemplate;
@Autowired
public CustomerRepository customerRepository;
public void saveNewLocation(Customer customer) {
customerRepository.save(customer);
}
public List<Customer> getLocationMembers(){
GeoDistanceQueryBuilder geoDistanceQueryBuilder = QueryBuilders
.geoDistanceQuery("customer")
.point(29.976, 31.131)
.distance(10, DistanceUnit.KILOMETERS);
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withFilter(geoDistanceQueryBuilder)
.build();
return elasticsearchTemplate.queryForList(searchQuery,Customer.class);
}
}
@Test
public void testLocation() {
Customer customer = new Customer();
customer.setName("base");
customer.setCifNo(1242343);
customer.setGeoPoint(new GeoPoint(29.876, 31.231));
locationFinder.saveNewLocation(customer);
List<Customer> customerList = locationFinder.getLocationMembers();
Assert.assertNotEquals(0,customerList.size());
}
Failed to execute phase [dfs], all shards failed
; shardFailures {[v4sPjgozTueAfeXoU4Ua5w][customer][0]: RemoteTransportException[[mertaksu-MBP][127.0.0.1:9300][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[failed to find geo_point field [customer]]; }{[v4sPjgozTueAfeXoU4Ua5w][customer][1]: RemoteTransportException[[mertaksu-MBP][127.0.0.1:9300][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[failed to find geo_point field [customer]]; }{[v4sPjgozTueAfeXoU4Ua5w][customer][2]: RemoteTransportException[[mertaksu-MBP][127.0.0.1:9300][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[failed to find geo_point field [customer]]; }{[v4sPjgozTueAfeXoU4Ua5w][customer][3]: RemoteTransportException[[mertaksu-MBP][127.0.0.1:9300][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[failed to find geo_point field [customer]]; }{[v4sPjgozTueAfeXoU4Ua5w][customer][4]: RemoteTransportException[[mertaksu-MBP][127.0.0.1:9300][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[failed to find geo_point field [customer]]; }
at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:534)
at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:305)
at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:563)
at org.elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:384)
at org.elasticsearch.action.search.AbstractSearchAsyncAction.access$200(AbstractSearchAsyncAction.java:65)
at org.elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:241)
at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:59)
at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:423)
at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1120)
at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1229)
at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1203)
at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:60)
at org.elasticsearch.action.search.SearchTransportService$2.onFailure(SearchTransportService.java:323)
at org.elasticsearch.action.ActionListener$1.onFailure(ActionListener.java:71)
at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:65)
at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:58)
at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:73)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:44)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:773)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:830)
Caused by: [customer/fSg6OP_fT0OIG4JAiUFhgA] QueryShardException[failed to find geo_point field [customer]]
at org.elasticsearch.index.query.GeoDistanceQueryBuilder.doToQuery(GeoDistanceQueryBuilder.java:235)
at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:99)
at org.elasticsearch.index.query.QueryShardContext.lambda$toQuery$1(QueryShardContext.java:331)
at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:343)
at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:330)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:749)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:586)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:545)
at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:309)
at org.elasticsearch.search.SearchService.lambda$executeDfsPhase$0(SearchService.java:305)
at org.elasticsearch.action.ActionListener.lambda$map$2(ActionListener.java:146)
at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:63)
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
{"customer":{"mappings":{"properties":{"cifNo":{"type":"long"},"geoPoint":{"type":"geo_point"},"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}}
必须使用以下字段生成geopoint查询:
GeoDistanceQueryBuilder geoDistanceQueryBuilder = QueryBuilders
.geoDistanceQuery("geoPoint")
.point(29.976, 31.131)
.distance(10, DistanceUnit.KILOMETERS);
顺便说一句,如果属性的类型为GeoPoint
,则不需要@GeoPointField
批注,如果类是GeoPoint
或存在批注,则将其映射到geo_point。
我正试图在基巴纳创建一个带有地理位置点的平铺地图。出于某种原因,当我尝试创建地图时,我在Kibana上收到以下消息: 没有兼容的字段:“日志”索引模式不包含以下任何字段类型:geo_point 我的设置: Logstash (版本 2.3.1): 当日志输入到达时,我可以看到它按照应该的方式解析它,并且我确实获得了给定IP的地理IP数据: ElasticSearch(版本 2.3.1): GET
我正在运行Elasticsearch版本1.5.2。Logstash版本1.5.4。 大多数logstash设置都是默认的: 我检查了映射“http://localhost:9200/logstash-2015.09.15?pretty”,并且geoip.location映射为double而不是geo_point。 有什么建议如何正确地映射这个? 更多信息:
问题内容: 我在Elasticsearch中有这样的数据 现在我想为位置字段设置geo_point。我已经尝试过这种方式 但这让我出错 你能帮我吗 谢谢 问题答案: 是您存储在中的对象的属性,因此请尝试执行以下操作: 请注意,从ES 2.0版本开始,字段名称可能不包含点
问题内容: 我想将一些JSON保留为看起来像这样的elastic(search): 点是具有弹性的geo_point类型的列表。因为它们是geo_point值,所以我需要定义索引映射,但是我能看到的最接近的方法是: 这意味着让每个点都是具有单个位置键和geo_point值的地图。我只想要geo_points,这可能吗? 问题答案: 您可以如下定义映射:
问题内容: 我正在尝试在matplotlib绘图中使用字体“ Heuristica”,但不会显示。 我在rcParameter font.serif的第一个位置上定义了“ Heuristica”->没有结果 我将font.family更改为“ Heuristica”,并收到消息 这让我开始思考,因为已经安装了Heuristica,并且可以从其他软件访问它而没有问题。所以我使用了fontManage
问题内容: 我正在尝试传递给jasper报告字符串位置的模板。因此,我在模板和值中传递了参数的键。当我在项目中有图像时,一切都在工作,但我想在另一个地方使用它。有什么方法可以从例如属性文件中读取参数?我不知道为什么这种解决方案不起作用: 我的形象: … 错误: 问题答案: 好的,我找到了…应该是: