When I carry out a search I look for documents with a lang code of 'en' and 'gen', im trying to ensure that the 'en' ones appear before the 'gen' ones do. So after looking around, I found this Boosting that might fit the bill as I don't want to completely exclude the 'gen' results..just drop the score a tad.
Below is what I have so far.. when I try to use the .Boosting, it renders the .Bool section unuseable.. Still quite new to this so any help would be greatly appreciate
SearchDescriptor<ExpandoObject> searchDescriptor = new SearchDescriptor<ExpandoObject>()
.Index(!searchModel.IndexesToSearch.Any() ? Indices.All : Indices.Index(searchModel.IndexesToSearch))
.From(searchModel.IndexOfLastResult)
.Size(searchModel.AmountOfResults)
.MinScore(searchModel.MinnimumResultScore)
.SearchType(SearchType.DfsQueryThenFetch);
IPromise<IList<ISort>> SortDescriptor(SortDescriptor<ExpandoObject> s) => s.Field(searchModel.SortByField, searchModel.SortByOrder);
List<Func<QueryContainerDescriptor<ExpandoObject>, QueryContainer>> filters = new List<Func<QueryContainerDescriptor<ExpandoObject>, QueryContainer>>();
foreach (var filter in searchModel.FilterValues)
{
filters.Add(fq => fq.Terms(t => t.Field(filter.FieldToSearch.Trim()).Terms(filter.Values)));
}
searchDescriptor
.Query(q => q
//.Boosting(b => b
// .Name("language")
// .Negative(qq => qq
// .MatchAll(m => m
// .Name("gen")))
// .NegativeBoost(0.2)
.Bool(b => b
.Should(s => s
.MultiMatch(m => m
.Fields( string.Join(',', searchModel.FieldsToSearch))
.Query(searchModel.SearchTerm)))
.Filter(filters)
)).Sort(SortDescriptor);