2016-11-30 84 views
-4
// 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>是什么?在NEST API中解释参数定义

+0

这是一个真正的方法是什么?不应该是'MatchPhrasePrefix'(.....'???这个编译就不会这么说吧 – user3185569

+0

不,这是查询容器中给出的方法的定义 请解释一下? MtachPhrasePrefix (Func ,IMatchQuery> selector) – suraj

回答

0

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

这是NEST, the high level .NET Elasticsearch client.The client supports both fluent API and an object initializer syntax.流畅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") 
     ) 
    ) 
); 
+0

.Query(“Prefix phrase”)是什么意思? – suraj

+0

这是match_phrase_prefix查询的输入:https://www.elastic.co/guide/en/elasticsearch/参考/ 5.0/query-dsl-match-query-phrase-prefix.html –

+0

非常感谢你的先生:) – suraj