ElasticSearch 7.13.4.如何通过编号获取文档

mgdq6dx1  于 4个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(60)

我正在用自己的.Net爬虫测试ElasticSearch。它工作得很好。但是我注意到一些搜索会产生响应错误,

query - all shards failed - Type: illegal_argument_exception Reason: "The length [1140599] of field [contents] in doc[19800]/index[myindex] exceeds the [index.highlight.max_analyzed_offset] limit [1000000].

字符串
我可以增加max_analyzed_offset并对问题进行排序,但我真正想做的是完整地查看文档。错误通过其序号索引- doc[19800]/index[myindex]给了我文档。据我所知,19800指的是索引中的文档编号,它不是文档ID,所以我需要访问的是索引中的文档# 19800。有没有一种方法可以使用ElasticSearch 7.13.4 API查看此文档(doc[19800]/index[myindex])?

r3i60tvu

r3i60tvu1#

看起来你分享的错误消息是由Elasticsearch 7.13中的这行代码产生的:

"The length [" + fieldValueLength + "] of field [" + field +"] in doc[" + docId + "]/index[" + index +"] exceeds the ["
                    + IndexSettings.MAX_ANALYZED_OFFSET_SETTING.getKey() + "] limit [" + maxAnalyzedOffset + "].
...

字符串
参考:https://github.com/elastic/elasticsearch/blob/7.13/server/src/main/java/org/apache/lucene/search/uhighlight/CustomUnifiedHighlighter.java#L123
因此,错误消息中的数字实际上是文档ID(docId)。
使用id获取整个文档的最简单方法是使用GET API。
参见Elasticsearch Guide [7], GET API

相关问题