# What if all filter not applied ? filter with null FIELD VALUE not NULL value in DOC

**URL:** <https://discuss.elastic.co/t/what-if-all-filter-not-applied-filter-with-null-field-value-not-null-value-in-doc/259063>\
**Category:** Elasticsearch\
**Created:** [December 18, 2020, 7:10am UTC](https://discuss.elastic.co/t/what-if-all-filter-not-applied-filter-with-null-field-value-not-null-value-in-doc/259063 "2020-12-18T07:10:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kajal\_Pandya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kajal_pandya/32/81092_2.png) [@Kajal\_Pandya](https://discuss.elastic.co/u/Kajal_Pandya)\
**Post date:** [December 18, 2020, 7:10am UTC](https://discuss.elastic.co/t/what-if-all-filter-not-applied-filter-with-null-field-value-not-null-value-in-doc/259063/1 "2020-12-18T07:10:01Z")

</div>

I have search for subjects..Teacher can add multiple subjects and students can search thode subject and can apply filter on resulted data..student can filter by **LEVEL, CURRICULUM, LOCATION**..

My query is what if student has not applied LOCATION filter?

Of i pass Location string in filter everything works fine for me..but when i do not apply LOCATION filter..it gives me **No text specified for text query**..

here is my query :

```auto
    $client = ClientBuilder::create()->build();
    $location = $request->location;
    $level = $request->level;
    $curriculum = $request->curriculum;
    $params = [
        'index' => 'tutors',
        'body' => 
     	[
            "query" => [
                "bool" => [
                	"must" => [
                		["term" => [ "approved" => 1]],
                    	["match" => [ "country_en_name" => $location]],
                     	["match" => [ "local_rates.levels" => $level]],
                     	["match" => [ "local_rates.curriculums" => $curriculum]],
                	]
                ],
            ]
        ]
    ];
    $search = $client->search($params);

```

I have also tried like this for NULL or EMPTY value

```auto
    $client = ClientBuilder::create()->build();
    $location = $request->location;
    $level = $request->level;
    $curriculum = $request->curriculum;
    $params = [
        'index' => 'tutors',
        'body' => 
     	[
            "query" => [
                "bool" => [
                	"must" => [
                		["term" => [ "approved" => 1]],
                    	$location && $location != null ? ["match" => [ "country_en_name" => $location]] : '',
                     	$level && $level != null ? ["match" => [ "local_rates.levels" => $level]] : '',
                        $curriculum && $curriculum != null ? ["match" => [ "local_rates.curriculums" => $curriculum]] : '',
                	]
                ],
            ]
        ]
    ];
    $search = $client->search($params);

```

Can anyone helps me out?

---

<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:** [January 15, 2021, 7:10am UTC](https://discuss.elastic.co/t/what-if-all-filter-not-applied-filter-with-null-field-value-not-null-value-in-doc/259063/2 "2021-01-15T07:10:03Z")

</div>

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