我的query_string查询给了我一个TooManyClauses异常。但是,在我的情况下,我不认为由于the usual reason引发了异常。相反,它似乎与突出显示有关,因为当我从查询中删除突出显示时,它可以工作。这是我原来的疑问:
{
"query" : {
"query_string" : {
"query" : "aluminium potassium +DOS_UUID:*",
"default_field" : "fileTextContent.fileTextContentAnalyzed"
}
},
"fields" : [ "attachmentType", "DOS_UUID", "ATT_UUID", "DOCUMENT_REFERENCE", "filename", "isCSR", "mime" ],
"highlight" : {
"fields" : {
"fileTextContent.fileTextContentAnalyzed" : { }
}
}
}
它给了我TooManyClauses错误:
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[02Z45jhrTCu7bSYy-XSW_g][markosindex][0]: FetchPhaseExecutionException[[markosindex][0]: query[filtered(fileTextContent.fileTextContentAnalyzed:aluminium fileTextContent.fileTextContentAnalyzed:potassium +DOS_UUID:*)->cache(_type:markostype)],from[0],size[10]: Fetch Failed [Failed to highlight field [fileTextContent.fileTextContentAnalyzed]]]; nested: TooManyClauses[maxClauseCount is set to 1024]; }]",
"status": 500
}
这是没有突出显示的查询,有效:
{
"query" : {
"query_string" : {
"query" : "aluminium potassium +DOS_UUID:*",
"default_field" : "fileTextContent.fileTextContentAnalyzed"
}
},
"fields" : [ "attachmentType", "DOS_UUID", "ATT_UUID", "DOCUMENT_REFERENCE", "filename", "isCSR", "mime" ]
}
更新1:
这是ElasticSearch日志文件中的堆栈跟踪:
[2014-10-10 16:03:18,236][DEBUG][action.search.type ] [Doop] [markosindex][0], node[02Z45jhrTCu7bSYy-XSW_g], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@14d7ab1e]
org.elasticsearch.search.fetch.FetchPhaseExecutionException: [markosindex][0]: query[filtered(fileTextContent.fileTextContentAnalyzed:aluminium fileTextContent.fileTextContentAnalyzed:potassium +DOS_UUID:*)->cache(_type:markostype)],from[0],size[10]: Fetch Failed [Failed to highlight field [fileTextContent.fileTextContentAnalyzed]]
at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:121)
at org.elasticsearch.search.highlight.HighlightPhase.hitExecute(HighlightPhase.java:126)
at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:211)
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:340)
at org.elasticsearch.search.action.SearchServiceTransportAction$11.call(SearchServiceTransportAction.java:308)
at org.elasticsearch.search.action.SearchServiceTransportAction$11.call(SearchServiceTransportAction.java:305)
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)
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)
Caused by: org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024
at org.apache.lucene.search.ScoringRewrite$1.checkMaxClauseCount(ScoringRewrite.java:72)
at org.apache.lucene.search.ScoringRewrite$ParallelArraysTermCollector.collect(ScoringRewrite.java:149)
at org.apache.lucene.search.TermCollectingRewrite.collectTerms(TermCollectingRewrite.java:79)
at org.apache.lucene.search.ScoringRewrite.rewrite(ScoringRewrite.java:105)
at org.apache.lucene.search.MultiTermQuery.rewrite(MultiTermQuery.java:288)
at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.extract(WeightedSpanTermExtractor.java:217)
at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.extract(WeightedSpanTermExtractor.java:99)
at org.elasticsearch.search.highlight.CustomQueryScorer$CustomWeightedSpanTermExtractor.extractUnknownQuery(CustomQueryScorer.java:89)
at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.extract(WeightedSpanTermExtractor.java:224)
at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.getWeightedSpanTerms(WeightedSpanTermExtractor.java:474)
at org.apache.lucene.search.highlight.QueryScorer.initExtractor(QueryScorer.java:217)
at org.apache.lucene.search.highlight.QueryScorer.init(QueryScorer.java:186)
at org.apache.lucene.search.highlight.Highlighter.getBestTextFragments(Highlighter.java:197)
at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:113)
... 9 more
[2014-10-10 16:03:18,237][DEBUG][action.search.type ] [Doop] All shards failed for phase: [query_fetch]
注意:我使用的是ElasticSearch 1.2.1。
更新2:
这是我的映射:
{
"markosindex": {
"mappings": {
"markostype": {
"_id": {
"path": "DOCUMENT_REFERENCE"
},
"properties": {
"ATT_UUID": {
"type": "string",
"index": "not_analyzed"
},
"DOCUMENT_REFERENCE": {
"type": "string",
"index": "not_analyzed"
},
"DOS_UUID": {
"type": "string",
"index": "not_analyzed"
},
"attachmentType": {
"type": "string",
"index": "not_analyzed"
},
"fileTextContent": {
"type": "string",
"index": "no",
"fields": {
"fileTextContentAnalyzed": {
"type": "string"
}
}
},
"filename": {
"type": "string",
"index": "not_analyzed"
},
"isCSR": {
"type": "boolean"
},
"mime": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
有什么想法吗?谢谢!