Here is my data, It’s based on a schema and I need to generate mapping to be indexed on ES. My background with ES is not much but I thought I got it until I tried it and failed and can’t find the right answer online..
error: BadRequestError(400, ‘mapper_parsing_exception’, ‘Expected map for property [fields] on field [type] but got a class java.lang.String’)
from elasticsearch import Elasticsearch
es = Elasticsearch("http://localhost:9200")
mapping = {
"mappings": {
"properties": {
"companyID": {"type": "keyword"},
"client": {"type": "keyword"},
"userID": {"type": "keyword"},
"campaignID": {"type": "keyword"},
"attachedCampaigns": {"type": "nested",
"properties": {
"campaignID": {"type": "keyword"},
"attachedAt": {"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"},
"removedAt": {"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"},
"attached": {"type": "boolean"},
"status": {"type": "text"},
"attachedBy": {"type": "keyword"},
"userID": {"type": "keyword"}
}
},
"jobSeekerID": {"type": "text"},
"sharedArticleID": {"type": "keyword"},
"status": {"type": "text"},
"personnelStatus": {"type": "text"},
"employmentStatus": {"type": "text"},
"availability": {"type": "text"},
"tagID": {"type": "keyword"},
"active": {"type": "boolean"},
"openApply": {"type": "boolean"},
"resume": {
"properties": {
"profile": {
"properties": {
"fullName": {"type": "text"},
"firstName": {"type": "text"},
"middleName": {"type": "text"},
"lastName": {"type": "text"},
"nickName": {"type": "text"},
"nameSuffix": {"type": "text"},
"emails": {
"properties": {
"text": {"type": "text"},
"email": {"type": "text"},
"type": {"type": "text"},
"preferred": {"type": "text"},
"confidenceScore": {"type": "integer"},
"valid": {"type": "boolean"},
"verified": {"type": "boolean"},
"subscribeStatus": {"type": "text"}
}
},
"phones": {
"properties": {
"text": {"type": "text"},
"phoneNumberOnly": {"type": "text"},
"internationalPhoneCode": {"type": "text"},
"nationalPhoneCode": {"type": "text"},
"country": {"type": "text"},
"countryCode": {"type": "text"},
"type": {"type": "text"},
"preferred": {"type": "text"},
"DNDStatus": {"type": "text"},
"confidenceScore": {"type": "integer"},
"valid": {"type": "boolean"},
"verified": {"type": "boolean"},
"subscribeStatus": {"type": "text"},
"ontology": {"type": "boolean"}
}
},
"websites": {
"properties": {
"type": "keyword"
}
},
"skypeID": {"type": "text"},
"locations": {
"properties": {
"text": {"type": "text"},
"tier": {"type": "text"},
"address": {"type": "text"},
"addressType": {"type": "text"},
"area": {"type": "text"},
"city": {"type": "text"},
"district": {"type": "text"},
"state": {"type": "text"},
"stateCode": {"type": "text"},
"country": {"type": "text"},
"countryCode": {"type": "text"},
"postalCode": {"type": "text"},
"pin": {"type": "geo_point",
"properties": {
"lat": {"type": "text"},
"lon": {"type": "text"}
}
},
"cityCanonical": {"type": "text"},
"districtCanonical": {"type": "text"},
"stateCanonical": {"type": "text"},
"countryCanonical": {"type": "text"},
"foundInResume": {"type": "boolean"},
"confidenceScore": {"type": "integer"}
}
},
"gender": {
"properties": {
"text": {"type": "text"},
"label": {"type": "text"},
"found": {"type": "boolean"}
}
},
"ethnicity": {"type": "text"},
"veteranStatus": {"type": "text"},
"languagesKnown": {"type": "nested",
"properties": {
"type": "text"
}
},
"age": {
"properties": {
"text": {"type": "text"},
"inYears": {"type": "integer"},
"found": {"type": "boolean"},
"confidenceScore": {"type": "integer"}
}
},
"dob": {
"properties": {
"text": {"type": "text"},
"standard": {"type": "text"},
"month": {"type": "text"},
"date": {"type": "text"},
"year": {"type": "text"},
"confidenceScore": {"type": "integer"}
}
},
"nationality": {
"properties": {
"text": {"type": "text"},
"label": {"type": "text"},
"nationalityCanonical": {"type": "text"},
"ethnicity": {"type": "text"},
"country": {"type": "text"},
"countryCode": {"type": "text"},
}
},
"maritalStatus": {"type": "text"},
"fatherName": {"type": "text"},
"motherName": {"type": "text"},
"spouseName": {"type": "text"},
"passport": {"type": "object",
"properties": {
"passportNumber": {"type": "text"},
"country": {"type": "text"},
"countryCode": {"type": "text"},
"expiryDate": {
"properties": {
"text": {"type": "text"},
"standard": {"type": "text"},
"date": {"type": "text"},
"month": {"type": "text"},
"year": {"type": "text"}
}
}
}
},
"profileImage": {
"properties": {
"content": {"type": "text"},
"fileName": {"type": "text"}
}
}
}
},
"professionalQualification": {
"properties": {
"certifications": {
"properties": {
"campus": {
"properties": {
"text": {"type": "text"},
"canonical": {"type": "text"},
"type": {"type": "text"},
"confidenceScore": {"type": "integer"}
}
},
"course": {
"properties": {
"text": {"type": "text"},
"canonical": {"type": "keyword"},
"type": {"type": "text"},
}
},
"merit": {
"properties": {
"percentage": {"type": "double"},
"GPA": {"type": "double"},
"GPAOutOf": {"type": "double"},
}
},
"currentStatus": {"type": "text"},
"startDate": {
"properties": {
"text": {"type": "text"},
"standard": {"type": "text"},
"year": {"type": "text"},
"month": {"type": "text"},
"date": {"type": "text"},
}
},
"endDate": {
"properties": {
"text": {"type": "text"},
"standard": {"type": "text"},
"year": {"type": "text"},
"month": {"type": "text"},
"date": {"type": "text"},
}
},
"expiryDate": {
"properties": {
"text": {"type": "text"},
"standard": {"type": "text"},
"year": {"type": "text"},
"month": {"type": "text"},
"date": {"type": "text"},
}
},
"duration": {
"properties": {
"text": {"type": "integer"},
"inYears": {"type": "double"},
"years": {"type": "integer"},
"months": {"type": "integer"},
"days": {"type": "integer"},
}
},
"location": {
"properties": {
"text": {"type": "text"},
"tier": {"type": "text"},
"address": {"type": "text"},
"area": {"type": "text"},
"city": {"type": "text"},
"district": {"type": "text"},
"state": {"type": "text"},
"stateCode": {"type": "text"},
"country": {"type": "text"},
"countryCode": {"type": "text"},
"postalCode": {"type": "text"},
"pin": {
"type": "geo_point",
"properties": {
"lat": {"type": "text"},
"lon": {"type": "text"}
}
},
"cityCanonical": {"type": "text"},
"districtCanonical": {"type": "text"},
"stateCanonical": {"type": "text"},
"countryCanonical": {"type": "text"}
}
},
"description": {"type": "text"}
}
},
"academicProjects": {
"properties": {
"campus": {
"properties": {
"text": {"type": "text"},
"canonical": {"type": "text"},
"type": {"type": "text"},
"confidenceScore": {"type": "integer"}
}
},
"university": {
"properties": {
"text": {"type": "text"},
"canonical": {"type": "text"},
"type": {"type": "text"},
"confidenceScore": {"type": "integer"}
}
},
"projectTitle": {"type": "text"},
"startDate": {
"properties": {
"text": {"type": "text"},
"standard": {"type": "text"},
"year": {"type": "text"},
"month": {"type": "text"},
"date": {"type": "text"},
}
},
"endDate": {
"properties": {
"text": {"type": "text"},
"standard": {"type": "text"},
"year": {"type": "text"},
"month": {"type": "text"},
"date": {"type": "text"},
}
},
"duration": {
"properties": {
"text": {"type": "text"},
"inYears": {"type": "double"},
"years": {"type": "integer"},
"months": {"type": "integer"},
"days": {"type": "integer"},
}
},
"skills": {
"properties": {"type": "keyword"}
},
"location": {
"properties": {
"text": {"type": "text"},
"tier": {"type": "text"},
"address": {"type": "text"},
"area": {"type": "text"},
"city": {"type": "text"},
"district": {"type": "text"},
"state": {"type": "text"},
"stateCode": {"type": "text"},
"country": {"type": "text"},
"countryCode": {"type": "text"},
"postalCode": {"type": "text"},
"pin": {
"type": "geo_point",
"properties": {
"lat": {"type": "text"},
"lon": {"type": "text"}
}
},
"cityCanonical": {"type": "text"},
"districtCanonical": {"type": "text"},
"stateCanonical": {"type": "text"},
"countryCanonical": {"type": "text"}
}
},
"description": {"type": "text"}
}
},
"skills": {
"properties": {
"text": {"type": "text"},
"canonical": {
"type": "text"
},
"canonicalDetails": {"type": "keyword"},
"relations": {"type": "keyword"},
"derived": {"type": "keyword"},
"yearsOfExperience": {"type": "double"},
"score": {"type": "double"},
"confidenceScore": {"type": "integer"},
"ontology": {"type": "boolean"},
"importance": {"type": "text"}
}
}
}
},
"professionalExperience": {
"properties": {
"company": {
"properties": {
"text": {"type": "text"},
"redFlag": {"type": "boolean"},
"canonical": {"type": "text"},
"canonicalDetails": {"type": "keyword"},
"confidenceScore": {"type": "integer"}
}
},
"jobTitle": {
"properties": {
"text": {"type": "text"},
"jobType": {"type": "text"},
"jobCategory": {"type": "text"},
"jobTitles": {
"properties": {
"jobTitle": {"type": "text"},
"canonical": {
"properties": {
"type": "text"
}
}
}
},
"confidenceScore": {"type": "integer"},
}
},
"skills": {
"properties": {
"text": {"type": "text"},
"canonical": {"type": "text"},
"canonicalDetails": {"type": "keyword"},
"relations": {"type": "keyword"},
"derived": {"type": "keyword"},
"yearsOfExperience": {"type": "integer"},
"score": {"type": "integer"},
"confidenceScore": {"type": "integer"},
"ontology": {"type": "boolean"},
"importance": {"type": "text"}
}
}
}
},
},
"genAISummary": {
"type": "text"
},
"createdAt": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"lastActiveAt": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss
},
"verifiedAt": {
"type": "text"
},
"verified": {"type": "boolean"},
"avoidActivities": {
"type": "keyword"
},
"exportDetails": {
"properties": {
"status": {"type": "text"},
"message": {"type": "text"},
"lastExportedAt": {"type": "text"},
"exportID": {"type": "keyword"}
}
}
}
}
}
}
try:
response = es.indices.create(index="my_index", body=mapping)
print(response)
except Exception as e:
print(str(e))
New contributor
Mannem Saiteja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1