Table of Contents

Method HasAncestor

Namespace
MongoDB.Driver.Search
Assembly
MongoDB.Driver.dll

HasAncestor<TField>(FieldDefinition<TDocument, IEnumerable<TField>>, SearchDefinition<TDocument>, SearchScoreDefinition<TDocument>)

Creates a search definition that moves the context back up the tree of embedded documents to one of the ancestors of the current embedded document such that ancestor fields can be used in searches of embedded documents.

public SearchDefinition<TDocument> HasAncestor<TField>(FieldDefinition<TDocument, IEnumerable<TField>> path, SearchDefinition<TDocument> @operator, SearchScoreDefinition<TDocument> score = null)

Parameters

path FieldDefinition<TDocument, IEnumerable<TField>>

The path from the root to the ancestor.

operator SearchDefinition<TDocument>

The operator to execute in the ancestor context specified by path.

score SearchScoreDefinition<TDocument>

The score modifier.

Returns

SearchDefinition<TDocument>

A search definition for the ancestor.

Type Parameters

TField

The type of the ancestor documents.

HasAncestor<TField>(Expression<Func<TDocument, IEnumerable<TField>>>, SearchDefinition<TDocument>, SearchScoreDefinition<TDocument>)

Creates a search definition that moves the context back up the tree of embedded documents to one of the ancestors of the current embedded document such that ancestor fields can be used in searches of embedded documents.

public SearchDefinition<TDocument> HasAncestor<TField>(Expression<Func<TDocument, IEnumerable<TField>>> path, SearchDefinition<TDocument> @operator, SearchScoreDefinition<TDocument> score = null)

Parameters

path Expression<Func<TDocument, IEnumerable<TField>>>

The path from the root to the ancestor.

operator SearchDefinition<TDocument>

The operator to execute in the ancestor context specified by path.

score SearchScoreDefinition<TDocument>

The score modifier.

Returns

SearchDefinition<TDocument>

A search definition for the ancestor.

Type Parameters

TField

The type of the ancestor documents.