Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Nest/Search/Search/InnerHits/InnerHits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public interface IInnerHits

[JsonProperty("docvalue_fields")]
Fields DocValueFields { get; set; }

[JsonProperty("ignore_unmapped")]
bool? IgnoreUnmapped { get; set; }
}

public class InnerHits : IInnerHits
Expand All @@ -61,6 +64,8 @@ public class InnerHits : IInnerHits
public IScriptFields ScriptFields { get; set; }

public Fields DocValueFields { get; set; }

public bool? IgnoreUnmapped { get; set; }
}

[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
Expand All @@ -76,6 +81,7 @@ public class InnerHitsDescriptor<T> : DescriptorBase<InnerHitsDescriptor<T>, IIn
bool? IInnerHits.Version { get; set; }
IScriptFields IInnerHits.ScriptFields { get; set; }
Fields IInnerHits.DocValueFields { get; set; }
bool? IInnerHits.IgnoreUnmapped { get; set; }

public InnerHitsDescriptor<T> From(int? from) => Assign(a => a.From = from);

Expand Down Expand Up @@ -107,5 +113,7 @@ public InnerHitsDescriptor<T> DocValueFields(Func<FieldsDescriptor<T>, IPromise<
Assign(a => a.DocValueFields = fields?.Invoke(new FieldsDescriptor<T>())?.Value);

public InnerHitsDescriptor<T> DocValueFields(Fields fields) => Assign(a => a.DocValueFields = fields);

public InnerHitsDescriptor<T> IgnoreUnmapped(bool? ignoreUnmapped = true) => Assign(a => a.IgnoreUnmapped = ignoreUnmapped);
}
}
10 changes: 6 additions & 4 deletions src/Tests/Search/Request/InnerHitsUsageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public void Seed()
)
.Mappings(map => map
.Map<King>(RoyalType, m => m

.AutoMap()
.Properties(props =>
RoyalProps(props)
Expand Down Expand Up @@ -162,7 +161,7 @@ private void IndexAll<TRoyal, TParent>(BulkDescriptor bulk, Func<IEnumerable<TRo
}

/**
* [[inner-hits-usage]]
* [[inner-hits-usage]]
*== Inner Hits Usage
*
* The {ref_current}/mapping-parent-field.html[parent/child] and {ref_current}/nested.html[nested] features allow the
Expand Down Expand Up @@ -244,7 +243,8 @@ public QueryInnerHitsApiTests(IntrusiveOperationCluster cluster, EndpointUsage u
highlight = new
{
fields = new { fullTextField = new { } }
}
},
ignore_unmapped = false
}
}
},
Expand Down Expand Up @@ -272,6 +272,7 @@ public QueryInnerHitsApiTests(IntrusiveOperationCluster cluster, EndpointUsage u
.DocValueFields(f=>f.Field(p=>p.Name))
.Name("princes")
.Highlight(h=>h.Fields(f=>f.Field(p=>p.FullTextField)))
.IgnoreUnmapped(false)
)

) || q.Nested(n => n
Expand All @@ -291,7 +292,8 @@ public QueryInnerHitsApiTests(IntrusiveOperationCluster cluster, EndpointUsage u
{
Name = "princes",
DocValueFields = Field<Prince>(p=>p.Name),
Highlight = Highlight.Field(Field<Prince>(p=>p.FullTextField))
Highlight = Highlight.Field(Field<Prince>(p=>p.FullTextField)),
IgnoreUnmapped = false
}
} || new NestedQuery
{
Expand Down