我有提供自动完成所需的功能,该功能只返回索引中特定类型的文档。
我有一个自动完成的建议工作没有上下文应用。但当我尝试绘制上下文时,它失败了。
这是我的地图。
.Map<MyType>(l => l
.Properties(p => p
.Boolean(b => b
.Name(n => n.IsArchived)
)
.String(s => s
.Name(n => n.Type)
.Index(FieldIndexOption.No)
)
.AutoMap()
.Completion(c => c
.Name(n => n.Suggest)
.Payloads(false)
.Context(context => context
.Category("type", cat => cat
.Field(field => field.Type)
.Default(new string[] { "defaultType" })
)
)
)
)
不确定我做错了什么,因为intellisense或build中没有任何错误。
Context Suggester映射不正确,无法按原样编译;AutoMap()
不是PropertiesDescriptor<T>
上的方法,而是PutMappingDescriptor<T>
上的方法。看看作为集成测试一部分使用的完成提示映射。它应该看起来像下面的
public class MyType
{
public bool IsArchived { get; set;}
public string Type { get; set;}
public CompletionField<object> Suggest { get; set;}
}
client.Map<MyType>(l => l
.AutoMap()
.Properties(p => p
.Boolean(b => b
.Name(n => n.IsArchived)
)
.String(s => s
.Name(n => n.Type)
.Index(FieldIndexOption.No)
)
.Completion(c => c
.Name(n => n.Suggest)
.Context(context => context
.Category("type", cat => cat
.Field(field => field.Type)
.Default("defaultType")
)
)
)
)
);
这导致以下映射
{
"properties": {
"isArchived": {
"type": "boolean"
},
"type": {
"type": "string",
"index": "no"
},
"suggest": {
"type": "completion",
"context": {
"type": {
"type": "category",
"path": "type",
"default": [
"defaultType"
]
}
}
}
}
}