@@ -64,6 +64,8 @@ public QueryDescriptor()
64
64
internal FuzzyLikeThisDescriptor < T > FuzzyLikeThisDescriptor { get ; set ; }
65
65
[ JsonProperty ( PropertyName = "has_child" ) ]
66
66
internal object HasChildQueryDescriptor { get ; set ; }
67
+ [ JsonProperty ( PropertyName = "has_parent" ) ]
68
+ internal object HasParentQueryDescriptor { get ; set ; }
67
69
[ JsonProperty ( PropertyName = "mlt" ) ]
68
70
internal MoreLikeThisQueryDescriptor < T > MoreLikeThisDescriptor { get ; set ; }
69
71
[ JsonProperty ( PropertyName = "range" ) ]
@@ -133,6 +135,7 @@ internal QueryDescriptor<T> Clone()
133
135
134
136
FuzzyLikeThisDescriptor = FuzzyLikeThisDescriptor ,
135
137
HasChildQueryDescriptor = HasChildQueryDescriptor ,
138
+ HasParentQueryDescriptor = HasParentQueryDescriptor ,
136
139
MoreLikeThisDescriptor = MoreLikeThisDescriptor ,
137
140
RangeQueryDescriptor = RangeQueryDescriptor ,
138
141
@@ -528,6 +531,21 @@ public BaseQuery HasChild<K>(Action<HasChildQueryDescriptor<K>> selector) where
528
531
return new QueryDescriptor < T > { HasChildQueryDescriptor = this . HasChildQueryDescriptor } ;
529
532
}
530
533
/// <summary>
534
+ /// The has_child query works the same as the has_child filter, by automatically wrapping the filter with a
535
+ /// constant_score.
536
+ /// </summary>
537
+ /// <typeparam name="K">Type of the child</typeparam>
538
+ public BaseQuery HasParent < K > ( Action < HasParentQueryDescriptor < K > > selector ) where K : class
539
+ {
540
+ var query = new HasParentQueryDescriptor < K > ( ) ;
541
+ selector ( query ) ;
542
+ if ( query . IsConditionless )
543
+ return CreateConditionlessQueryDescriptor ( query ) ;
544
+
545
+ this . HasParentQueryDescriptor = query ;
546
+ return new QueryDescriptor < T > { HasParentQueryDescriptor = this . HasParentQueryDescriptor } ;
547
+ }
548
+ /// <summary>
531
549
/// The top_children query runs the child query with an estimated hits size, and out of the hit docs, aggregates
532
550
/// it into parent docs. If there arent enough parent docs matching the requested from/size search request,
533
551
/// then it is run again with a wider (more hits) search.
0 commit comments