in tablestore/src/main/java/com/alicloud/openservices/tablestore/core/protocol/SearchProtocolParser.java [127:195]
static FieldSchema toFieldSchema(Search.FieldSchema fieldSchema) {
FieldSchema result = new FieldSchema(fieldSchema.getFieldName(),
toFieldType(fieldSchema.getFieldType()));
if (fieldSchema.hasIndex()) {
result.setIndex(fieldSchema.getIndex());
}
if (fieldSchema.hasSortAndAgg()) {
result.setEnableSortAndAgg(fieldSchema.getSortAndAgg());
}
if (fieldSchema.hasEnableHighlighting()) {
result.setEnableHighlighting(fieldSchema.getEnableHighlighting());
}
if (fieldSchema.hasStore()) {
result.setStore(fieldSchema.getStore());
}
if (fieldSchema.hasIsArray()) {
result.setIsArray(fieldSchema.getIsArray());
}
if (fieldSchema.hasIndexOptions()) {
result.setIndexOptions(toIndexOptions(fieldSchema.getIndexOptions()));
}
if (fieldSchema.hasAnalyzer()) {
result.setAnalyzer(FieldSchema.Analyzer.fromString(fieldSchema.getAnalyzer()));
}
if (fieldSchema.hasAnalyzerParameter()) {
FieldSchema.Analyzer analyzer = FieldSchema.Analyzer.fromString(fieldSchema.getAnalyzer());
try {
switch (analyzer) {
case SingleWord:
result.setAnalyzerParameter(toAnalyzerParameter(
Search.SingleWordAnalyzerParameter.parseFrom(fieldSchema.getAnalyzerParameter())
));
break;
case Split:
result.setAnalyzerParameter(toAnalyzerParameter(
Search.SplitAnalyzerParameter.parseFrom(fieldSchema.getAnalyzerParameter())
));
break;
case Fuzzy:
result.setAnalyzerParameter(toAnalyzerParameter(
Search.FuzzyAnalyzerParameter.parseFrom(fieldSchema.getAnalyzerParameter())
));
break;
}
} catch (InvalidProtocolBufferException e) {
throw new ClientException("failed to parse single_word analyzer parameter: " + e.getMessage());
}
}
if (fieldSchema.getFieldSchemasList() != null) {
List<FieldSchema> subSchemas = new ArrayList<FieldSchema>();
for (Search.FieldSchema subSchema : fieldSchema.getFieldSchemasList()) {
subSchemas.add(toFieldSchema(subSchema));
}
result.setSubFieldSchemas(subSchemas);
}
if (fieldSchema.hasIsVirtualField()) {
result.setVirtualField(fieldSchema.getIsVirtualField());
}
result.setSourceFieldNames(fieldSchema.getSourceFieldNamesList());
result.setDateFormats(fieldSchema.getDateFormatsList());
if (fieldSchema.hasVectorOptions()) {
result.setVectorOptions(toVectorOptions(fieldSchema.getVectorOptions()));
}
if (fieldSchema.hasJsonType()) {
result.setJsonType(toJsonType(fieldSchema.getJsonType()));
}
return result;
}