TotalTermFreq必须至少为docFreq错误

时间:2019-09-01 15:30:01

标签: elasticsearch

我在我的elasticsearch(ElasticSearch版本7)映射中添加了新字段,如下所示。

"productTags": {"type": "text", "store": true, "fields": {"keyword": {"type": "keyword"}}}

当我执行在productTags字段中具有匹配项的查询时,出现此错误:

Caused by: java.lang.IllegalArgumentException: totalTermFreq must be at least docFreq, totalTermFreq: 44, docFreq: 68

有趣的是,如果我在索引中查询productTags字段中未包含 的搜索字词,则该查询很好。但是,一旦我查询了包含productTags的结果的搜索词,就会得到此堆栈跟踪。

您能否提供有关我需要进行研究以解决此问题的提示?关于“ totalTermFreq必须至少为docFreq”的搜索不会返回很多结果。

堆栈跟踪:

[2019-09-01T11:18:05,438][DEBUG][o.e.a.s.TransportSearchAction] [MacBook-Pro.local] All shards failed for phase: [query]
org.elasticsearch.ElasticsearchException$1: totalTermFreq must be at least docFreq, totalTermFreq: 44, docFreq: 68
    at org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:639) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:137) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:259) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.search.InitialSearchPhase.onShardFailure(InitialSearchPhase.java:105) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.search.InitialSearchPhase.access$200(InitialSearchPhase.java:50) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.search.InitialSearchPhase$2.onFailure(InitialSearchPhase.java:273) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.search.SearchExecutionStatsCollector.onFailure(SearchExecutionStatsCollector.java:73) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:59) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:441) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1124) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1236) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1210) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:60) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.action.support.ChannelActionListener.onFailure(ChannelActionListener.java:56) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.SearchService$2.onFailure(SearchService.java:366) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:360) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:354) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.SearchService$4.doRun(SearchService.java:1069) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) [elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.0.1.jar:7.0.1]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_191]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_191]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
Caused by: java.lang.IllegalArgumentException: totalTermFreq must be at least docFreq, totalTermFreq: 44, docFreq: 68
    at org.apache.lucene.search.TermStatistics.<init>(TermStatistics.java:73) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.IndexSearcher.termStatistics(IndexSearcher.java:768) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.elasticsearch.search.internal.ContextIndexSearcher.termStatistics(ContextIndexSearcher.java:193) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.apache.lucene.search.TermQuery$TermWeight.<init>(TermQuery.java:64) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.TermQuery.createWeight(TermQuery.java:205) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.IndexSearcher.createWeight(IndexSearcher.java:717) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.elasticsearch.search.internal.ContextIndexSearcher.createWeight(ContextIndexSearcher.java:134) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.apache.lucene.search.DisjunctionMaxQuery$DisjunctionMaxWeight.<init>(DisjunctionMaxQuery.java:109) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.DisjunctionMaxQuery.createWeight(DisjunctionMaxQuery.java:205) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.IndexSearcher.createWeight(IndexSearcher.java:717) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.elasticsearch.search.internal.ContextIndexSearcher.createWeight(ContextIndexSearcher.java:134) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.apache.lucene.search.BooleanWeight.<init>(BooleanWeight.java:54) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.BooleanQuery.createWeight(BooleanQuery.java:207) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.IndexSearcher.createWeight(IndexSearcher.java:717) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.elasticsearch.search.internal.ContextIndexSearcher.createWeight(ContextIndexSearcher.java:134) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.apache.lucene.search.BooleanWeight.<init>(BooleanWeight.java:54) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.BooleanQuery.createWeight(BooleanQuery.java:207) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.apache.lucene.search.IndexSearcher.createWeight(IndexSearcher.java:717) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.elasticsearch.search.internal.ContextIndexSearcher.createWeight(ContextIndexSearcher.java:134) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:443) ~[lucene-core-8.0.0.jar:8.0.0 2ae4746365c1ee72a0047ced7610b2096e438979 - jimczi - 2019-03-08 11:58:55]
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:275) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:115) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:349) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:393) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.SearchService.access$100(SearchService.java:124) ~[elasticsearch-7.0.1.jar:7.0.1]
    at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:358) ~[elasticsearch-7.0.1.jar:7.0.1]
    ... 9 more

1 个答案:

答案 0 :(得分:0)

看来这是ElasticSearch 7.1版中的bug。在7.2中为resolved。现在,我将ElasticSearch升级到7.3,我的问题已解决。