# Mapping null values

**URL:** <https://discuss.elastic.co/t/mapping-null-values/292900>\
**Category:** Elasticsearch\
**Created:** [December 24, 2021, 2:48pm UTC](https://discuss.elastic.co/t/mapping-null-values/292900 "2021-12-24T14:48:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emile\_Plas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emile_plas/32/84542_2.png) [@Emile\_Plas](https://discuss.elastic.co/u/Emile_Plas)\
**Post date:** [December 24, 2021, 2:48pm UTC](https://discuss.elastic.co/t/mapping-null-values/292900/1 "2021-12-24T14:48:07Z")

</div>

Hey everyone!

I am quite new to Elasticsearch so feel free to criticize my work method. I am currently working on a project in which multiple pdf documents (a series of court decisions) need to be searched. The PDF documents are ingested into Elasticsearch via FSCrawler (thank you daadonet for this amazing program). For all the new documents that are created, I want to make sure that they have certain properties. In my case, each decision has e.g. a CourtInstance, DecissionDate, etc. At the moment of ingesting the data via fscrawler I would like to set these values by default to null, so that they can, later on, be adapted based on a query. To test things out I created a test query:

```auto
POST _reindex
{
  "source": {
	  "index": "courtdecissions"
}, 
  "dest": {
	  "index": "testindex"
}
}

```

Then I added the following mapping:

```auto
PUT /testindex/_mapping
{
  "properties":{
    "CourtCategory":{
      "type": "keyword",
      "null_value": "null"
    },
    "CourtInstance": {
      "type": "keyword",
      "null_value": "NULL"
    },
    "DecissionDate": {
      "type": "date",
      "null_value": "NULL"
    },
    "DecissionNumber":{
      "type": "keyword",
      "null_value": "NULL"
    },
    "CaseNumber":{
      "type": "keyword",
      "null_value": "NULL"
    },
    "References":{
      "type": "text"
    },
    "Summaries":{
      "type": "text"
    },
    "Comments": {
      "type": "text"
    }
  }
}

```

This seems to work fine since I can find the updated mapping via "GET /testindex/\_mapping"

Afterward, I reindex using the POST \_reindex mentioned above.

However, when I query for a null value, nothing returns:

```auto
GET /testindex/_search
{
  "query": {
    "term": {
        "CaseNumber": "NULL"
    }
  }
}

```

Any suggestions or ideas? Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Emile\_Plas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emile_plas/32/84542_2.png) [@Emile\_Plas](https://discuss.elastic.co/u/Emile_Plas)\
**Post date:** [December 24, 2021, 4:02pm UTC](https://discuss.elastic.co/t/mapping-null-values/292900/2 "2021-12-24T16:02:17Z")

</div>

Ok. I solved it by adding the following pipeline to the index:

```auto
PUT _ingest/pipeline/courtdecissionspipeline
{
  "version": 1,
  "description": "provide default values for several fields", 
  "processors": [
    {"set": 
      {
        "field": "CourtCategory",
        "value": "undefined"
      }
    },
    {
      "set": {
        "field": "CourtInstance",
        "value": "undefined"
      }
    },
    {
      "set": {
        "field": "DecissionDate",
        "value": "0001-01-01"
      }
    },
    {
      "set": {
        "field": "DecissionNumber",
        "value": "undefined"
      }
    },
    {
      "set": {
        "field": "CaseNumber",
        "value": "undefined"
      }
    },
    {
      "set": {
        "field": "References",
        "value": "[]"
      }
    },
    {
      "set": {
        "field": "Summaries",
        "value": "[]"
      }
    },
    {
      "set": {
        "field": "Comments",
        "value": "[]"
      }
    }
  ]
}

```

After deleting the index I recreated the index:

```auto
PUT /testindex
{
  "mappings": 
  {
    "properties":{
    "CourtCategory":{
      "type": "keyword",
      "null_value": "undefined"
    },
    "CourtInstance": {
      "type": "keyword",
      "null_value": "NULL"
    },
    "DecissionDate": {
      "type": "date",
      "null_value": "0001-01-01"
    },
    "DecissionNumber":{
      "type": "keyword",
      "null_value": "NULL"
    },
    "CaseNumber":{
      "type": "keyword",
      "null_value": "NULL"
    },
    "References":{
      "type": "text"
    },
    "Summaries":{
      "type": "text"
    },
    "Comments": {
      "type": "text"
    }
  }
  },
  "settings": {
    "index": {
      "default_pipeline": "courtdecissionspipeline"
    }
  }
}

```

Afterward, I restarted the FSCrawler and now the file has the necessary default values. If there are any other suggestions from a more 'expert' view, please let me know!

---

<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 21, 2022, 4:02pm UTC](https://discuss.elastic.co/t/mapping-null-values/292900/3 "2022-01-21T16:02:26Z")

</div>

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