我有一个包含ParentType文档的索引。 ParentType有一个NestedType对象列表,这些对象被定义为嵌套在elasticsearch术语中。您可以在下面看到对象的架构。
[ElasticType(Name = "parentType")]
public class ParentType
{
public string Id { get; set; }
public List<NestedType> NestedTypes { get; set; }
}
[ElasticType(Name = "nestedType")]
public class NestedType
{
public string Field1 { get; set; }
public string Field2 { get; set; }
}
索引中这些类型的映射由以下代码定义。
_client.CreateIndex(c => c
.Index(_indexName)
.InitializeUsing(_indexSettings)
.AddMapping<RealPersonSm>(m => m
.Properties(p => p
.NestedObject<NestedType>(n => n
.Name("nestedTypes")
.MapFromAttributes()
.IncludeInParent()
.IncludeInAll())
.String(s => s
.Name(rp => rp.Id)
.IncludeInAll(false)
.Index(FieldIndexOption.NotAnalyzed)))));
我希望能够在嵌套对象的所有字段中进行搜索。
当使用带有多匹配内部查询的嵌套查询时,我明确指定嵌套字段,返回预期结果。
{
"query": {
"nested": {
"query": {
"multi_match": {
"query": "query terms",
"fields": [
"nestedType.field1",
"nestedType.field2"]
}
},
"path": "nestedTypes"
}
}
}
}
但是,当我使用带有匹配内部查询的嵌套查询和&#34; _all&#34;选项为字段,不返回任何结果。
{
"query": {
"nested": {
"query": {
"match": {
"_all": "query terms"
}
},
"path": "nestedTypes"
}
}
}
}
匹配查询是否存在特定问题&#34; _all&#34;在引用嵌套对象的字段时是字段选项还是我在过程中遗漏了某些内容?
我正在使用elasticsearch 1.4和NEST 1.6.1。