mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-25 06:16:40 +00:00
Improve the error message when loading text fielddata. (#52753)
Emphasize keyword over fielddata as the preferred way to use String fields for aggregations or sorting.
This commit is contained in:
parent
662f21fcea
commit
d3c0a2f013
@ -131,7 +131,7 @@ public class GraphIT extends ESRestHighLevelClientTestCase {
|
||||
assertThat(exploreResponse.isTimedOut(), Matchers.is(false));
|
||||
ShardOperationFailedException[] failures = exploreResponse.getShardFailures();
|
||||
assertThat(failures.length, Matchers.equalTo(1));
|
||||
assertTrue(failures[0].reason().contains("Fielddata is disabled"));
|
||||
assertTrue(failures[0].reason().contains("Text fields are not optimised for operations that require per-document field data"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -757,9 +757,10 @@ public class TextFieldMapper extends FieldMapper {
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
if (fielddata == false) {
|
||||
throw new IllegalArgumentException("Fielddata is disabled on text fields by default. Set fielddata=true on [" + name()
|
||||
+ "] in order to load fielddata in memory by uninverting the inverted index. Note that this can however "
|
||||
+ "use significant memory. Alternatively use a keyword field instead.");
|
||||
throw new IllegalArgumentException("Text fields are not optimised for operations that require per-document "
|
||||
+ "field data like aggregations and sorting, so these operations are disabled by default. Please use a "
|
||||
+ "keyword field instead. Alternatively, set fielddata=true on [" + name() + "] in order to load "
|
||||
+ "field data by uninverting the inverted index. Note that this can use significant memory.");
|
||||
}
|
||||
return new PagedBytesIndexFieldData.Builder(fielddataMinFrequency, fielddataMaxFrequency, fielddataMinSegmentSize);
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ public class TextFieldMapperTests extends ESSingleNodeTestCase {
|
||||
FieldMapper fieldMapper = (FieldMapper) disabledMapper.mappers().getMapper("field");
|
||||
fieldMapper.fieldType().fielddataBuilder("test");
|
||||
});
|
||||
assertThat(e.getMessage(), containsString("Fielddata is disabled"));
|
||||
assertThat(e.getMessage(), containsString("Text fields are not optimised for operations that require per-document field data"));
|
||||
|
||||
mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("properties").startObject("field")
|
||||
|
Loading…
x
Reference in New Issue
Block a user