解释NEST API中的参数定义

时间:2016-11-30 08:17:38

标签: c# visual-studio-2010 elasticsearch nest

// Summary:
//     The text_phrase_prefix is the same as text_phrase, expect it allows for prefix
//     matches on the last term in the text

public QueryContainer MatchPhrasePrefix<T>(Func<MatchPhrasePrefixQueryDescriptor<T>, IMatchQuery> selector);

有人可以解释一下Func<MatchPhrasePrefixQueryDescriptor<T>, IMatchQuery>是什么吗?

1 个答案:

答案 0 :(得分:0)

这是一个接受委托/方法/ lambda表达式作为参数的方法,它接受MatchPhrasePrefixQueryDescriptor<T>作为参数并返回IMatchQuery实例。

它是assertEquals NEST, the high level .NET Elasticsearch client.的流畅API的一部分正如其他人所指出的那样,该方法是通用的,MatchPhrasePrefix<T>

使用

public class Document
{
    public string Property1 { get; set; }
}

var searchResponse = client.Search<Document>(s => s
    .Query(q => q
        .MatchPhrasePrefix(p => p
            .Field(f => f.Property1)
            .Query("Prefix phrase")
        )
    )
);