I want to allow these two objects to be indexed:
{ "name": "foo", "value": 12}
{"name": "bar", "value": "twelve"}
where I want to store the object and index on name but not on value.
Is that possible?
I want to allow these two objects to be indexed:
{ "name": "foo", "value": 12}
{"name": "bar", "value": "twelve"}
where I want to store the object and index on name but not on value.
Is that possible?
In the same index?
Yes, same index.
The following incantation seems to work. If I index a document with a numeric 'value' property, it seems to retain its number type even though the mapping type is text.
{
"settings": {
},
"mappings": {
"_default_": {
"dynamic_templates": [
{
"value_is_any_type": {
"match": "value",
"mapping": {
"type": "text"
}
}
},
{
"timestamp": {
"match": "timestamp",
"mapping": {
"type": "date"
}
}
}
]
}
}
}
It won't, it will convert it to text because that is the lowest common denominator.
Inneresting. I was looking at the record which retains the integer. At least it actually stored the record (rather than rejecting it).
But as you rightly say the index doesn't see that property as integer.
I am avoiding the problem by adjusting my json prop names. The lesson is, I think, use a static type per (nested) prop name.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.