# Storing Ansible facts in Elasticsearch (JSON) & mapper parsing exception

**URL:** <https://discuss.elastic.co/t/storing-ansible-facts-in-elasticsearch-json-mapper-parsing-exception/68053>\
**Category:** Elasticsearch\
**Created:** [December 5, 2016, 2:10pm UTC](https://discuss.elastic.co/t/storing-ansible-facts-in-elasticsearch-json-mapper-parsing-exception/68053 "2016-12-05T14:10:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [December 6, 2016, 10:43am UTC](https://discuss.elastic.co/t/storing-ansible-facts-in-elasticsearch-json-mapper-parsing-exception/68053/2 "2016-12-06T10:43:32Z")

</div>

Hi,

> [@sndr](#):
>
> why there seems to be some automatic assumption of what a value in JSON

I guess you should read a little bit about how mappings work in Elasticsearch. See e.g. [reference docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) and the [Definitive Guide](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/mapping-analysis.html). This will help you a lot. 🙂

On to your problem. Based on what you write I infer that you use Elasticsearch 5. There is also a [factbeat](https://github.com/jarpy/factbeat) that gathers data with facter and puts them into Elasticsearch. It also defines a mapping and you can use that for your index. Note that the author states in the README that facter 3 should be used as it produces more structured output.

First we remove the index again:

```auto
DELETE /facts

```

Then please also remove _all_ index tempates:

```auto
DELETE /_template/*

```

Finally you can add your index template (as I said, this is based on the factbeat index template):

```auto
PUT /_template/facts
{
  "mappings": {
    "_default_": {
      "_all": {
        "enabled": true,
        "norms": {
          "enabled": false
        }
      },
      "dynamic_templates": [
        {
          "template1": {
            "mapping": {
              "doc_values": true,
              "ignore_above": 1024,
              "index": "not_analyzed",
              "type": "{dynamic_type}"
            },
            "match": "*"
          }
        }
      ],
      "properties": {
        "@timestamp": {
          "type": "date"
        }
      }
    }
  },
  "settings": {
    "index.refresh_interval": "5s"
  },
  "template": "facts-*"
}

```

Then you can add an example document:

```auto
POST /facts/my-fact/1
{
    "ansible_local": {
        "updates_facter": {
            "Packages": {
                "Installed": {
                    "acl": "2.2.52-3"
                }
            }
        }
    }
}

```

and delete it again:

```auto
DELETE /facts/my-fact/1

```

Daniel

---

_[View the full topic](https://discuss.elastic.co/t/storing-ansible-facts-in-elasticsearch-json-mapper-parsing-exception/68053)._
