private PB.FieldSchema EncodingFieldSchema(DataModel.Search.FieldSchema fieldSchema)
        {
            var builder = PB.FieldSchema.CreateBuilder();

            builder.SetFieldName(fieldSchema.FieldName);
            builder.SetFieldType(EncodingFieldType(fieldSchema.FieldType));
            if (fieldSchema.FieldType != DataModel.Search.FieldType.NESTED)
            {
                builder.Index     = fieldSchema.index;
                builder.DocValues = fieldSchema.EnableSortAndAgg;
                builder.Store     = fieldSchema.Store;
                builder.IsArray   = fieldSchema.IsArray;
            }

            if (fieldSchema.IndexOptions != DataModel.Search.IndexOptions.NULL)
            {
                builder.IndexOptions = EncodingIndexOptions(fieldSchema.IndexOptions);
            }
            if (fieldSchema.Analyzer != DataModel.Search.Analyzer.NotAnalyzed)
            {
                builder.Analyzer = EncodingAnalyzer(fieldSchema.Analyzer);
            }

            if (fieldSchema.SubFieldSchemas != null)
            {
                for (var i = 0; i < fieldSchema.SubFieldSchemas.Count; i++)
                {
                    builder.AddFieldSchemas(EncodingFieldSchema(fieldSchema.SubFieldSchemas[i]));
                }
            }

            return(builder.Build());
        }
        private DataModel.Search.FieldSchema ParseFieldSchema(PB.FieldSchema fieldSchema)
        {
            var ret = new DataModel.Search.FieldSchema(fieldSchema.FieldName, ParseFieldType(fieldSchema.FieldType));

            ret.Analyzer         = ParseAnalyzer(fieldSchema.Analyzer);
            ret.EnableSortAndAgg = fieldSchema.DocValues;
            ret.index            = fieldSchema.Index;
            ret.Store            = fieldSchema.Store;
            ret.IsArray          = fieldSchema.IsArray;
            ret.IndexOptions     = ParseIndexOption(fieldSchema.IndexOptions);
            foreach (var item in fieldSchema.FieldSchemasList)
            {
                ret.SubFieldSchemas.Add(ParseFieldSchema(item));
            }

            return(ret);
        }