# Filter Based On Average Score

**URL:** https://discuss.elastic.co/t/filter-based-on-average-score/239429
**Category:** Elasticsearch
**Created:** [July 1, 2020, 7:49am UTC](https://discuss.elastic.co/t/filter-based-on-average-score/239429 "2020-07-01T07:49:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zamkinos](https://avatars.discourse-cdn.com/v4/letter/z/9d8465/32.png) [@zamkinos](https://discuss.elastic.co/u/zamkinos)
#### Post date: [July 1, 2020, 7:49am UTC](https://discuss.elastic.co/t/filter-based-on-average-score/239429/1 "2020-07-01T07:49:54Z")

</div>

Hi, I have an index keeps items.  
My search structure like below:

```auto
    QueryContainer filterDescription = null;
    			QueryContainer filterItemNo = null;
    			QueryContainer filterModelNo = null;
    			QueryContainer queryMain = null;
    			
    			foreach (string inpValue in arrSearch)
    			{
    				filterDescription |= new WildcardQuery() { Field = "searchfor_description", Value = "*" + inpValue + "*" };
    				filterItemNo |= new WildcardQuery() { Field = "searchfor_itemno", Value = "*" + inpValue + "*" };
    				filterModelNo |= new WildcardQuery() { Field = "searchfor_modelno", Value = "*" + inpValue + "*" };
    				
    				queryMain &= new WildcardQuery() { Field = "searchfor_all", Value = "*" + inpValue + "*" };
    			}
    			
    			double weightItemNo = 10000;
    			double weightModelNo = 100;
    			double weightDescription = 1;

    			ElasticClient elasticClient = new ElasticClient(new ConnectionSettings(
                    new Uri("my url"))
                    .RequestTimeout(TimeSpan.FromMinutes(5))
                    .DefaultIndex("items")
                    );
    					
                ISearchResponse<items> seachResultItem = elasticClient.Search<items>(s => s
                    .RequestConfiguration(r => r.DisableDirectStreaming())
                    .From(filtre.PageNo == 1 ? 0 : (filtre.PageNo * filtre.PageCount) - filtre.PageCount)
                    .Size(filtre.PageCount)
                    .Sort(sc => sc.Descending(SortSpecialField.Score))
                    .Query(q => q
                     .FunctionScore(fs => fs
                            .Functions(fu => fu
                                .Weight(w => w
                                    .Weight(weightDescription)
                                    .Filter(wf => wf
                                    .Bool(bb => bb
                                    .Must(filterDescription))
                                    ))
                                )
                            .Functions(fu => fu
                                .Weight(w => w
                                    .Weight(weightItemNo)
                                    .Filter(wf => wf
                                    .Bool(bb => bb
                                    .Must(filterItemNo))
                                    ))
                                )
                            .Functions(fu => fu
                                .Weight(w => w
                                    .Weight(weightModelNo)
                                    .Filter(wf => wf
                                    .Bool(bb => bb
                                    .Must(filterModelNo))
                                    ))
                                )
                    .Query(q2 => q2
                        .Bool(b => b
                        .Should(queryMain))
                        )
                    ))
                );

```

I need to filter by average score.  
For example, written keywords match the item number field, and one of them matches the description field. Its score will be under average and I would not like to show it.  
I do not know if I've explained and I do not know if I'm going in the right way?

Kindly regards.

---

<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: [July 29, 2020, 7:49am UTC](https://discuss.elastic.co/t/filter-based-on-average-score/239429/2 "2020-07-29T07:49:56Z")

</div>

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