# No results when searching by a null value

**URL:** <https://discuss.elastic.co/t/no-results-when-searching-by-a-null-value/292385>\
**Category:** Elasticsearch\
**Created:** [December 18, 2021, 2:37pm UTC](https://discuss.elastic.co/t/no-results-when-searching-by-a-null-value/292385 "2021-12-18T14:37:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexBulls20](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@AlexBulls20](https://discuss.elastic.co/u/AlexBulls20)\
**Post date:** [December 18, 2021, 2:37pm UTC](https://discuss.elastic.co/t/no-results-when-searching-by-a-null-value/292385/1 "2021-12-18T14:37:10Z")

</div>

I'm trying to fill some value for an autocomplete search box and I had this old code (from Elasticsearch 1.5) and I want to implement it into Elasticsearch 7.16

When I use this sentence

```auto
curl -H 'Content-Type: application/json' -XGET localhost:9200/bne8/_search?pretty -d '{
  "suggest": {
    "bne_suggest": {
      "text": "*san*",
      "completion": {
        "field": "label_ac",
        "size": 20,
        "contexts": {
          "type": "null"
        }
      }
    }
  }
}'

```

I get this:

```auto
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  },
  "suggest" : {
    "bne_suggest" : [
      {
        "text" : "*san*",
        "offset" : 0,
        "length" : 5,
        "options" : []
      }
    ]
  }
}

```

When I changed the "type" : "null" to an actual value (for example "cars"), I get at least 20 hits.

My issue is:

How can I rewrite this code to make get all the possible hits without an explicit type (instead of having just "cars", having "cars", "bikes", "planes"....)

I tried with "type" : "\*" but doesn't work.

I'm new here and with Elasticsearch, so my apologizes if I write or do something wrong.

The mapping from "label\_ac"

```auto
"label_ac" : {
          "type" : "completion",
          "analyzer" : "default",
          "preserve_separators" : true,
          "preserve_position_increments" : true,
          "max_input_length" : 50,
          "contexts" : [
            {
              "name" : "type",
              "type" : "CATEGORY",
              "path" : "@type"
            }
          ]
        }

```

@type field is a text

---

<div class="post-metadata">

**Author:** ![AlexBulls20](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@AlexBulls20](https://discuss.elastic.co/u/AlexBulls20)\
**Post date:** [December 18, 2021, 3:23pm UTC](https://discuss.elastic.co/t/no-results-when-searching-by-a-null-value/292385/2 "2021-12-18T15:23:15Z")

</div>

It was the most silly thing, so, reviewing the old code I realized that I had a 'default' field with values, so I change the "null" with that array and its working.

---

<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, 2022, 3:23pm UTC](https://discuss.elastic.co/t/no-results-when-searching-by-a-null-value/292385/3 "2022-01-15T15:23:53Z")

</div>

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