I have a simple documents that get inserted by mongodb directly, it look like this:
PUT /office_db/employee/1
{
"employeeId": "5b5fc605357d0c6",
"formalName": "mark rose",
"socialNumber": 2147483647,
"contact": {
"name": "dave more",
"email": "dave@gmail.com",
"phone": 918493203
}
}
and I created a multi match query to search on 3 fields:
GET /office_db/employee/_search
{
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "214748364",
"fields": [
"formalName^-1.0",
"socialNumber^-1.0",
"contact.phone^-1.0"
],
"type": "phrase_prefix",
"lenient": "true"
}
}
]
}
}
}
my issue is that if I try to search for prefix of the socialNumber I dont get results, only if I put the whole number I get results. But if I search for prefix of the formalName I get results...is it possible because of the fields types?
this is my mappings:
{
"office_db": {
"mappings": {
"employee": {
"properties": {
"contact": {
"properties": {
"email": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"phone": {
"type": "long"
}
}
},
"employeeId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"formalName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"socialNumber": {
"type": "long"
}
}
}
}
}
}
I cant change the types really, does someone know what should I fix in the query in order for it to give me results for prefix of the numeric values?