我知道這是一個新的更改,但是我看不到這個映射有什麼問題。這是從通過_mapping呼叫ElasticSearch註冊領域的映射採取:ElasticSearch 5.x在文本字段上排序問題
"key": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
當我有點用「鑰匙」領域,我得到這個例外。我也嘗試添加fieldData = true,但這也沒有奏效。
Caused by: RemoteTransportException[[_6qwpaI][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: IllegalArgumentException[Fielddata is disabled on text fields by default. Set fielddata=true on [key] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.];
Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [key] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.
at org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:335)
at org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:111)
at org.elasticsearch.index.query.QueryShardContext.getForField(QueryShardContext.java:167)
at org.elasticsearch.search.sort.FieldSortBuilder.build(FieldSortBuilder.java:281)
at org.elasticsearch.search.sort.SortBuilder.buildSort(SortBuilder.java:151)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:678)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:536)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:502)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:243)
at org.elasticsearch.action.search.SearchTransportService.lambda$registerRequestHandler$6(SearchTransportService.java:276)
at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69)
at org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:550)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:527)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
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)
起初我以爲這可能與使用的字段(如key.keyword)的,但因爲我不這樣做,那麼我看不出有任何理由,爲什麼這是不工作。
我對ElasticSearch 5.x相當陌生,文檔自相矛盾,所以我希望有人能指出我正確的方向。這就是我指的是:
https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html
我基本上是試圖實現相同一直幹到5.x的這種原始的映射:
"mapping": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"ignore_above": 256
},
"english": {
"type": "string",
"analyzer": "english"
}
}
}
BTW,我覺得關鍵詞字段是自動生成的,因爲我甚至沒有在我的映射中定義它。
你能解決這個問題嗎?我面臨着類似的問題:( – askids
請看下面的答案,看看它是否有助於你的情況。 – juminoz