在构建文档时,给字段 setBoost 爆异常:
java.lang.IllegalArgumentException: You cannot set an index-time boost on an unindexed field, or one that omits norms
代码为:
Document doc = new Document();
Field f = new FloatField("x", 10.0, Field.Store.YES);
f.setBoost(10.0);
doc.add(f);
Lucene 版本 4.6.0, 求指教!
FieldType fieldType = new FieldType(StringField.TYPE_STORED);
fieldType.setOmitNorms(false);
Field countryField = new Field("country", country, getNormStringField());
countryField.setBoost("China".equals(country) ? 5f : 1f);
FloatField是不支持setBoost的。需要创建自定义的FieldType