use of com.qlangtech.tis.solrdao.SolrFieldsParser.SolrType in project tis by qlangtech.
the class PSchemaField method serialVisualType2Json.
@Override
public void serialVisualType2Json(JSONObject f) {
if (this.getType() == null) {
throw new IllegalStateException("field:" + this.getName() + " 's fieldType is can not be null");
}
// serialVisualType2Json(f, this.getType());
SolrFieldsParser.SolrType solrType = this.getType();
String type = solrType.getSType().getName();
TokenizerType tokenizerType = TokenizerType.parse(type);
if (tokenizerType == null) {
// 非分词字段
if (solrType.tokenizerable) {
setStringType(f, type, ReflectSchemaFieldType.STRING.literia);
} else {
f.put("split", false);
VisualType vtype = TokenizerType.visualTypeMap.get(type);
if (vtype != null) {
f.put(ISchemaField.KEY_FIELD_TYPE, vtype.getType());
return;
}
f.put(ISchemaField.KEY_FIELD_TYPE, type);
}
} else {
// 分词字段
setStringType(f, tokenizerType.getKey(), ReflectSchemaFieldType.STRING.literia);
}
// } else {
// throw new IllegalStateException("field:" + this.getName() + " 's fieldType is can not be null");
// }
}
use of com.qlangtech.tis.solrdao.SolrFieldsParser.SolrType in project tis by qlangtech.
the class SchemaAction method updateSchemaXML.
/**
* @param fieldTypes 已经存在的字段类型
* @param schemaForm
* @param document2
* @param modifier
*/
private static void updateSchemaXML(Map<String, SolrType> fieldTypes, ISchemaPluginContext schemaPlugin, ISchema schemaForm, Document document2, final XModifier modifier) {
SolrType type = null;
String fieldTypeRef = null;
FieldTypeFactory fieldTypeFactory = null;
String pluginName = null;
for (ISchemaField field : schemaForm.getSchemaFields()) {
modifySchemaProperty(modifier, field, "type", (fieldTypeRef = parseSolrFieldType(field)));
modifySchemaProperty(modifier, field, "stored", field.isStored());
modifySchemaProperty(modifier, field, "indexed", field.isIndexed());
modifySchemaProperty(modifier, field, "docValues", field.isDocValue());
modifySchemaProperty(modifier, field, "multiValued", field.isMultiValue());
type = fieldTypes.get(fieldTypeRef);
Objects.requireNonNull(type, "fieldName:" + field.getName() + " relevant fieldType can not be null");
if (type.plugin) {
pluginName = type.getPluginName();
fieldTypeFactory = schemaPlugin.findFieldTypeFactory(pluginName);
Objects.requireNonNull(fieldTypeFactory, "pluginName:" + pluginName + " relevant fieldTypeFactory can not be null");
fieldTypeFactory.process(document2, modifier);
}
}
if (StringUtils.isNotBlank(schemaForm.getUniqueKey())) {
modifySchemaProperty("/uniqueKey/text()", schemaForm.getUniqueKey(), modifier);
} else {
modifier.deleteUniqueKey();
}
if (StringUtils.isNotBlank(schemaForm.getSharedKey())) {
modifySchemaProperty("/sharedKey/text()", schemaForm.getSharedKey(), modifier);
} else {
modifier.deleteSharedKey();
}
}
use of com.qlangtech.tis.solrdao.SolrFieldsParser.SolrType in project tis by qlangtech.
the class SchemaAction method mergeWfColsWithTplCollection.
/**
* 通过解析workflow的最终导出的字段,来生成Schema配置
*
* @param module
* @param context
* @param appSource
* @return
* @throws Exception
*/
public static SchemaResult mergeWfColsWithTplCollection(BasicModule module, Context context, ISolrAppSource appSource, final ISchemaPluginContext schemaPlugin, SolrFieldsParser.ParseResultCallback... parseResultCallback) throws Exception {
// 通过version取默认模板
Application tplApp = getTemplateApp(module);
SchemaResult tplSchema = getTemplateSchema(module, context, tplApp);
if (!tplSchema.isSuccess()) {
return null;
}
ParseResult parseResult = (ParseResult) tplSchema.getParseResult();
SolrType strType = parseResult.getTisType(ReflectSchemaFieldType.STRING.literia);
List<ColumnMetaData> cols = appSource.reflectCols();
for (ColumnMetaData colName : cols) {
PSchemaField f = new PSchemaField();
f.setName(colName.getKey());
f.setType(strType);
f.setStored(true);
f.setIndexed(false);
f.setMltiValued(false);
f.setDocValue(false);
parseResult.dFields.add(f);
}
parseResult.setUniqueKey(null);
for (SolrFieldsParser.ParseResultCallback c : parseResultCallback) {
c.process(cols, parseResult);
}
parseResult.addReservedFields();
tplSchema.content = XModifier.modifySchemaContent(tplSchema.content, (document2, modifier) -> {
modifier.addModify("/fields/field(:delete)");
modifier.addModify("/sharedKey(:delete)");
modifier.deleteUniqueKey();
updateSchemaXML(parseResult.types, schemaPlugin, parseResult, document2, modifier);
});
parseResultCallback4test.process(cols, parseResult);
return tplSchema;
}
Aggregations