Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5727f7d

Browse files
russcamMpdreamz
authored andcommittedMar 19, 2018
Add ignore_unmapped to inner_hits (#3135)
Closes #3132
1 parent 6e0b861 commit 5727f7d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed
 

‎src/Nest/Search/Search/InnerHits/InnerHits.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public interface IInnerHits
3838

3939
[JsonProperty("docvalue_fields")]
4040
Fields DocValueFields { get; set; }
41+
42+
[JsonProperty("ignore_unmapped")]
43+
bool? IgnoreUnmapped { get; set; }
4144
}
4245

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

6366
public Fields DocValueFields { get; set; }
67+
68+
public bool? IgnoreUnmapped { get; set; }
6469
}
6570

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

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

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

109115
public InnerHitsDescriptor<T> DocValueFields(Fields fields) => Assign(a => a.DocValueFields = fields);
116+
117+
public InnerHitsDescriptor<T> IgnoreUnmapped(bool? ignoreUnmapped = true) => Assign(a => a.IgnoreUnmapped = ignoreUnmapped);
110118
}
111119
}

‎src/Tests/Search/Request/InnerHitsUsageTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public void Seed()
8888
)
8989
.Mappings(map => map
9090
.Map<King>(RoyalType, m => m
91-
9291
.AutoMap()
9392
.Properties(props =>
9493
RoyalProps(props)
@@ -162,7 +161,7 @@ private void IndexAll<TRoyal, TParent>(BulkDescriptor bulk, Func<IEnumerable<TRo
162161
}
163162

164163
/**
165-
* [[inner-hits-usage]]
164+
* [[inner-hits-usage]]
166165
*== Inner Hits Usage
167166
*
168167
* The {ref_current}/mapping-parent-field.html[parent/child] and {ref_current}/nested.html[nested] features allow the
@@ -244,7 +243,8 @@ public QueryInnerHitsApiTests(IntrusiveOperationCluster cluster, EndpointUsage u
244243
highlight = new
245244
{
246245
fields = new { fullTextField = new { } }
247-
}
246+
},
247+
ignore_unmapped = false
248248
}
249249
}
250250
},
@@ -272,6 +272,7 @@ public QueryInnerHitsApiTests(IntrusiveOperationCluster cluster, EndpointUsage u
272272
.DocValueFields(f=>f.Field(p=>p.Name))
273273
.Name("princes")
274274
.Highlight(h=>h.Fields(f=>f.Field(p=>p.FullTextField)))
275+
.IgnoreUnmapped(false)
275276
)
276277

277278
) || q.Nested(n => n
@@ -291,7 +292,8 @@ public QueryInnerHitsApiTests(IntrusiveOperationCluster cluster, EndpointUsage u
291292
{
292293
Name = "princes",
293294
DocValueFields = Field<Prince>(p=>p.Name),
294-
Highlight = Highlight.Field(Field<Prince>(p=>p.FullTextField))
295+
Highlight = Highlight.Field(Field<Prince>(p=>p.FullTextField)),
296+
IgnoreUnmapped = false
295297
}
296298
} || new NestedQuery
297299
{

0 commit comments

Comments
 (0)
Please sign in to comment.