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:
/my_index/ index, a schema with two fields: a field called
text and a field called
count with datatype
This automatic detection and addition of new fields is called dynamic typing.
By default, when a previously unseen field is found in a document, Xapiand will add the new field to the schema. This behaviour can be disabled globally by running the server in strict mode.
Assuming dynamic typing is enabled, some simple rules are used to determine which datatype the field should have:
|JSON datatype||Xapiand datatype|
|Floating point number||
These are the only field datatypes that are dynamically detected. Any other datatypes must be mapped explicitly.
datetime_detection is enabled (the default), then new string fields are
checked to see whether their contents match any of the date patterns. If a
match is found, a new datetime field is added.
Disabling datetime detection
Dynamic datetime detection can be disabled by setting
false in the index schema:
Then, when indexing a new field that looks like a date will not be detected
datetime and instead it will end up being a
While JSON has support for native floating point and integer datatypes, some applications or languages may sometimes render numbers as strings. Usually the correct solution is to map these fields explicitly, but numeric detection (which is disabled by default) can be enabled to do this automatically:
The following will detect
my_float field to be
my_integer to be