Answer the question
In order to leave comments, you need to log in
How to get _score value from ElasticSearch NEST?
elasticClient.Search<NewsForSearch>(s => s
.Index("newsindex")
.Type("newsforsearch")
.Query(qq =>
{
QueryContainer query = null;
//query &= q.Term(p => p.State, userInput.State.ToString());
if (!string.IsNullOrEmpty(forSearch))
query &= qq.Raw("{\"multi_match\" : {\"query\": \"" + forSearch + "\", \"fields\": [ \"title\", \"content\",\"description\",\"categoryName\",\"sourceName\",\"regionName\" ]}}");
// За последние 24 часа
query &= qq.DateRange(p => p.LessThanOrEquals(DateMath.Now).GreaterThan(DateMath.FromString(DateTime.Now.AddDays(-1).ToString())));
return query;
}).Sort(
ss =>
{
SortDescriptor<NewsForSearch> Sorting = new SortDescriptor<NewsForSearch>();
Sorting = Sorting.Descending("_score");
return Sorting;
}
));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question