# How to lower the score of documents that match a specific field and value using ElasticSearch DSL C#

**URL:** <https://discuss.elastic.co/t/how-to-lower-the-score-of-documents-that-match-a-specific-field-and-value-using-elasticsearch-dsl-c/279459>\
**Category:** Elasticsearch\
**Created:** [July 23, 2021, 8:48am UTC](https://discuss.elastic.co/t/how-to-lower-the-score-of-documents-that-match-a-specific-field-and-value-using-elasticsearch-dsl-c/279459 "2021-07-23T08:48:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jay2](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@Jay2](https://discuss.elastic.co/u/Jay2)\
**Post date:** [July 23, 2021, 8:48am UTC](https://discuss.elastic.co/t/how-to-lower-the-score-of-documents-that-match-a-specific-field-and-value-using-elasticsearch-dsl-c/279459/1 "2021-07-23T08:48:41Z")

</div>

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

```auto
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);

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 20, 2021, 8:48am UTC](https://discuss.elastic.co/t/how-to-lower-the-score-of-documents-that-match-a-specific-field-and-value-using-elasticsearch-dsl-c/279459/2 "2021-08-20T08:48:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
