I have a JSON file which looks like this:
{'name':'John Doe',
'work':[{
'company':'Google',
'duration':'2 years',
'desc':'some long text'},
{
'company':'Yahoo',
'duration':'3 years',
'desc':'some long text'}]}
There can be a number of entries in work from 0 to unknown. How do I define the elasticsearch mapping such that it gets stored automatically.
I tried something like this:
from elasticsearch import elasticsearch
mapping:{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"man":{
"properties": {
"name":{"type":"text"},
"work":{
"properties": {
"company" : {"type":"text"},
"duration": {"type":"text"},
"desc": {"type":"text"}
}
}
}
}
}
es = Elasticsearch()
if es.indices.exists("test"):
es.indices.delete(index="test")
es.indices.create("test")
es.indices.put_mapping(index="test", doc_type="man", body=mapping)
Please help me on this. Thanks.