- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用的是Elasticsearch 1.7.5创建索引名称“geo_ip
”后,我使用下面的 java 片段代码来搜索名称为 Turkey
的字段 country
。
String index = "geo_ip";
String type = "ip";
String field = "country";
String value = "Turkey";
Map<String, String> query = new HashMap<>();
query.put(field, value);
// create client
TransportClient client = EsLoading.settingElasticSearch();
// searching
SearchResponse response = client.prepareSearch(index)
.setTypes(type)
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(query)
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
SearchHit[] result = response.getHits().getHits();
System.out.println("Current result: "+result.length);
但是之后,它出现了这样的问题:
Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query_fetch], all shards failed; shardFailures {[uVH-OgzjQfuUV8Bg_nViHQ][geo_ip][0]: SearchParseException[[geo_ip][0]: from[0],size[60]: Parse Failure [Failed to parse source [{"from":0,"size":60,"query":{"country":"Turkey"},"explain":true}]]]; nested: QueryParsingException[[geo_ip] [_na] query malformed, no field after start_object]; }{[uVH-OgzjQfuUV8Bg_nViHQ][geo_ip][1]: SearchParseException[[geo_ip][1]: from[0],size[60]: Parse Failure [Failed to parse source [{"from":0,"size":60,"query":{"country":"Turkey"},"explain":true}]]]; nested: QueryParsingException[[geo_ip] [_na] query malformed, no field after start_object]; }{[uVH-OgzjQfuUV8Bg_nViHQ][geo_ip][2]: SearchParseException[[geo_ip][2]: from[0],size[60]: Parse Failure [Failed to parse source [{"from":0,"size":60,"query":{"country":"Turkey"},"explain":true}]]]; nested: QueryParsingException[[geo_ip] [_na] query malformed, no field after start_object]; }{[uVH-OgzjQfuUV8Bg_nViHQ][geo_ip][3]: SearchParseException[[geo_ip][3]: from[0],size[60]: Parse Failure [Failed to parse source [{"from":0,"size":60,"query":{"country":"Turkey"},"explain":true}]]]; nested: QueryParsingException[[geo_ip] [_na] query malformed, no field after start_object]; }{[uVH-OgzjQfuUV8Bg_nViHQ][geo_ip][4]: SearchParseException[[geo_ip][4]: from[0],size[60]: Parse Failure [Failed to parse source [{"from":0,"size":60,"query":{"country":"Turkey"},"explain":true}]]]; nested: QueryParsingException[[geo_ip] [_na] query malformed, no field after start_object]; }
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:237)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.onFailure(TransportSearchTypeAction.java:183)
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:565)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
有人可以帮我解决这个问题吗?谢谢。
最佳答案
您的country
字段可能已被分析,因此您需要使用小写的turkey
进行查询。试试这个:
SearchResponse response = client.prepareSearch(index)
.setTypes(type)
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(QueryBuilders.termQuery("country", "turkey"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
或者使用 match
查询(使用 turkey
或 Turkey
),如下所示:
SearchResponse response = client.prepareSearch(index)
.setTypes(type)
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(QueryBuilders.matchQuery("country", "Turkey"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
关于java - Elasticsearch 中的 SearchPhaseExecutionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38764308/
在我开始收到搜索查询错误之前,我的服务器运行良好: RequestError: TransportError(400, u'SearchPhaseExecutionException[Failed t
我在page的最后部分遵循了教程。 POST /merchantindex/_search { "function_score": { "query": { {"query_s
我正在使用Symfony 2.8。我目前遇到此错误。我尝试通过运行app/console fos:elastic:populate卸载并重新安装elasticsearch并再次填充集群。它们都不能解决
” 我使用的是Elasticsearch 1.7.5创建索引名称“geo_ip”后,我使用下面的 java 片段代码来搜索名称为 Turkey 的字段 country。 String index =
我在 elasticsearch 上运行了以下查询 curl -X GET "http://localhost:9200/games_201403031340/_search?pretty=true"
我实现了Tiree wih elasticsearch。 我的项目在本地运行良好,并且搜索索引没有问题。 但是,当我将应用程序部署到服务器时,出现以下错误消息: Tire::Search::Searc
最近我们的服务器在没有正确关闭 Elastic Search/Kibana 的情况下重新启动。重新启动后,两个应用程序都在运行,但不再创建索引。我在 Debug模式下检查了 logstash 设置,它
我正在使用Elasticsearch { "name" : "Angela Cairn", "cluster_name" : "prod-elastic", "cluster_uuid"
logstash 无法按单词搜索。异常(exception): 查询“* @timestamp:[2012-05-17 TO 2012-05-26]”导致以下错误:org.elasticsearch.
我是一名优秀的程序员,十分优秀!