Skip to content

Commit

Permalink
fix indexoption and analyzer default value error
Browse files Browse the repository at this point in the history
  • Loading branch information
伯箫 committed Jun 24, 2019
1 parent c1c5890 commit 8f91881
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sdk/Aliyun/OTS/DataModel/Search/FieldSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Aliyun.OTS.DataModel.Search
{
public enum Analyzer
{

NotAnalyzed,
SingleWord,
MaxWord

Expand Down
1 change: 1 addition & 0 deletions sdk/Aliyun/OTS/DataModel/Search/IndexOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/// </summary>
public enum IndexOptions
{
NULL,
DOCS,
FREQS,
POSITIONS,
Expand Down
11 changes: 7 additions & 4 deletions sdk/Aliyun/OTS/Handler/ProtocolBufferEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ private IMessage EncodeCreateSearchIndex(Request.OTSRequest request)
var requestReal = (Request.CreateSearchIndexRequest)request;
var builder = PB.CreateSearchIndexRequest.CreateBuilder();
builder.SetTableName(requestReal.TableName);
builder.SetIndexName(requestReal.IndexName);
builder.SetIndexName(requestReal.IndexName);
builder.SetSchema(EncodeIndexSchema(requestReal.IndexSchame));
return builder.Build();
}
Expand Down Expand Up @@ -515,8 +515,11 @@ private PB.FieldSchema EncodingFieldSchema(DataModel.Search.FieldSchema fieldSch
builder.IsArray = fieldSchema.IsArray;
}

builder.IndexOptions = EncodingIndexOptions(fieldSchema.IndexOptions);
if(fieldSchema.FieldType == DataModel.Search.FieldType.TEXT)
if (fieldSchema.IndexOptions != DataModel.Search.IndexOptions.NULL)
{
builder.IndexOptions = EncodingIndexOptions(fieldSchema.IndexOptions);
}
if (fieldSchema.Analyzer != DataModel.Search.Analyzer.NotAnalyzed)
{
builder.Analyzer = EncodingAnalyzer(fieldSchema.Analyzer);
}
Expand All @@ -525,7 +528,7 @@ private PB.FieldSchema EncodingFieldSchema(DataModel.Search.FieldSchema fieldSch
{
for (var i = 0; i < fieldSchema.SubFieldSchemas.Count; i++)
{
builder.SetFieldSchemas(i, EncodingFieldSchema(fieldSchema.SubFieldSchemas[i]));
builder.AddFieldSchemas(EncodingFieldSchema(fieldSchema.SubFieldSchemas[i]));
}
}

Expand Down

0 comments on commit 8f91881

Please sign in to comment.