<commit_before>---
title: Dynamic Typing
---

{: .note .construction }
_This section is a **work in progress**..._

One of the most important features of Xapiand is that it tries to get out of
your way and let you start exploring your data as quickly as possible. To index
a document, you don't have to first create an index, define a schema, and
define your fields; you can just index a document and the index, schema, and
fields will spring to life automatically:

{% capture req %}

```json
PUT /my_index/1

{
  "name": "<NAME>",
  "age": 20
}
```
{% endcapture %}
{% include curl.html req=req %}

Creates the `/my_index/` index, a schema with two fields: a field called `name`
with datatype `text` and a field called `count` with datatype `integer`.

This automatic detection and addition of new fields is called dynamic typing.

# Datatype Detection

By default, when a previously unseen field is found in a document, Xapiand will<commit_msg>Docs: Dynamic typing<commit_after>---
title: Dynamic Typing
---

One of the most important features of Xapiand is that it tries to get out of
your way and let you start exploring your data as quickly as possible. To index
a document, you don't have to first create an index, define a schema, and
define your fields; you can just index a document and the index, schema, and
fields will spring to life automatically:

{% capture req %}

```json
PUT /my_index/1

{
  "name": "<NAME>",
  "age": 20
}
```
{% endcapture %}
{% include curl.html req=req %}

{% comment %}

```js
pm.test("Response is success", function() {
  pm.response.to.be.success;
});
```

```json
GET /my_index/
```

```js
pm.test("Response is success", function() {
  pm.response.to.be.success;
});
```

```js
pm.test("Field 'name' is text", function() {
  var jsonData = pm.response.json();
  pm.expect(jsonData._schema.schema.name._type).to.equal("text");
});
```

```js
pm.test("Field 'age' is integer", function() {
  var jsonData = pm.response.json();
  pm.expect(jsonData._schema.schema.age._type).to.equal("integer");
});
```
{% endcomment %}

Creates the `/my_index/` index, a schema with two fields: a field called `name`
with datatype `text` and a field called `count` with datatype `integer`.

This automatic detection and addition of new fields is called dynamic typing.

# Datatype Detection

By default, when a previously unseen field is found in a document, Xapiand will
{'fraction_non_alphanumeric': 0.12390488110137672, 'fraction_numerical': 0.0025031289111389237, 'mean_word_length': 4.145922746781116, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5007065', 'n_tokens_mistral': 753, 'n_tokens_neox': 709, 'n_words': 315}