@@ -64,6 +64,8 @@ public QueryDescriptor()
6464 internal FuzzyLikeThisDescriptor < T > FuzzyLikeThisDescriptor { get ; set ; }
6565 [ JsonProperty ( PropertyName = "has_child" ) ]
6666 internal object HasChildQueryDescriptor { get ; set ; }
67+ [ JsonProperty ( PropertyName = "has_parent" ) ]
68+ internal object HasParentQueryDescriptor { get ; set ; }
6769 [ JsonProperty ( PropertyName = "mlt" ) ]
6870 internal MoreLikeThisQueryDescriptor < T > MoreLikeThisDescriptor { get ; set ; }
6971 [ JsonProperty ( PropertyName = "range" ) ]
@@ -133,6 +135,7 @@ internal QueryDescriptor<T> Clone()
133135
134136 FuzzyLikeThisDescriptor = FuzzyLikeThisDescriptor ,
135137 HasChildQueryDescriptor = HasChildQueryDescriptor ,
138+ HasParentQueryDescriptor = HasParentQueryDescriptor ,
136139 MoreLikeThisDescriptor = MoreLikeThisDescriptor ,
137140 RangeQueryDescriptor = RangeQueryDescriptor ,
138141
@@ -528,6 +531,21 @@ public BaseQuery HasChild<K>(Action<HasChildQueryDescriptor<K>> selector) where
528531 return new QueryDescriptor < T > { HasChildQueryDescriptor = this . HasChildQueryDescriptor } ;
529532 }
530533 /// <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>
531549 /// The top_children query runs the child query with an estimated hits size, and out of the hit docs, aggregates
532550 /// it into parent docs. If there arent enough parent docs matching the requested from/size search request,
533551 /// then it is run again with a wider (more hits) search.
0 commit comments