C# Elasticsearch.NET突出显示请求的嵌套对象初始值设定项语法
我有:C# Elasticsearch.NET突出显示请求的嵌套对象初始值设定项语法,c#,nest,object-initializers,
elasticsearch-net,C#,Nest,Object Initializers,
elasticsearch Net,我有: var result = _client.Search<ElasticFilm>(new SearchRequest("blaindex", "blatype") { From = 0, Size = 100, Query = titleQuery || pdfQuery, Source = new SourceFilter
var result = _client.Search<ElasticFilm>(new SearchRequest("blaindex", "blatype")
{
From = 0,
Size = 100,
Query = titleQuery || pdfQuery,
Source = new SourceFilter
{
Include = new []
{
Property.Path<ElasticFilm>(p => p.Url),
Property.Path<ElasticFilm>(p => p.Title),
Property.Path<ElasticFilm>(p => p.Language),
Property.Path<ElasticFilm>(p => p.Details),
Property.Path<ElasticFilm>(p => p.Id)
}
},
Timeout = "20000"
});
var result=\u client.Search(新的搜索请求(“blaindex”,“blatype”)
{
From=0,
尺寸=100,
Query=titleQuery | | pdfQuery,
Source=新的SourceFilter
{
Include=新[]
{
Path(p=>p.Url),
Property.Path(p=>p.Title),
Property.Path(p=>p.Language),
Property.Path(p=>p.Details),
Property.Path(p=>p.Id)
}
},
超时=“20000”
});
我正试图添加一个高亮过滤器,但我对对象初始值设定项(OIS)C#语法不太熟悉。我已经检查过了,但似乎无法返回任何特定于(OIS)的结果
我可以在Nest.SearchRequest类中看到Highlight属性,但我没有足够的经验(我猜)来简单地从那里构造我需要的东西-一些关于如何使用高亮笔和OIS的示例和解释将非常热门 这是流畅的语法:
var response= client.Search<Document>(s => s
.Query(q => q.Match(m => m.OnField(f => f.Name).Query("test")))
.Highlight(h => h.OnFields(fields => fields.OnField(f => f.Name).PreTags("<tag>").PostTags("</tag>"))));
自版本6起,
PropertyPathMarker
类已从嵌套库中删除。你知道新版本该怎么做吗?非常感谢。我发现缺少官方文档,并且正在寻找更广泛的文档/学习资源,包括整个NEST API。你能推荐其他的文档/学习资源吗?我认为官方的每一次都在变得越来越好。如果你在那里找不到任何帮助,我认为一个好主意是在社区中创建一个问题,让大家知道社区正在努力解决什么:)
var searchRequest = new SearchRequest
{
Query = new QueryContainer(new MatchQuery{Field = Property.Path<Document>(p => p.Name), Query = "test"}),
Highlight = new HighlightRequest
{
Fields = new FluentDictionary<PropertyPathMarker, IHighlightField>
{
{
Property.Path<Document>(p => p.Name),
new HighlightField {PreTags = new List<string> {"<tag>"}, PostTags = new List<string> {"</tag>"}}
}
}
}
};
var searchResponse = client.Search<Document>(searchRequest);
var searchQuery = new SearchRequest
{
Highlight = new Highlight
{
Fields = new FluentDictionary<Field, IHighlightField>()
.Add(Nest.Infer.Field<Document>(d => d.Name),
new HighlightField {PreTags = new[] {"<tag>"}, PostTags = new[] {"<tag>"}})
}
};
public class Document
{
public int Id { get; set; }
public string Name { get; set; }
}