I am new to Elasticsearch. We have certain data in different data-types that we want to index and retrieve. We are using custom "_all" fields as explained in the below link
Following is our code
For Creating Index
PUT myindex
{
"mappings": {
"mytype": {
"properties": {
"first_name": {
"type": "text",
"copy_to": "contact_details"
},
"mobile_number": {
"type": "long",
"copy_to": "contact_details"
},
"contact_details": {
"type": "text"
}
}
}
}
}
For Adding to Index
PUT myindex/mytype/1
{
"first_name": "John",
"mobile_number": 9988776655
}
For Search
GET myindex/_search
{
"query": {
"multi_match": {
"query": "9988776655",
"fields": [
"contact_details"
],
"fuzziness": "auto"
}
},
"highlight": {
"require_field_match": false,
"pre_tags": [
"<tag1>"
],
"post_tags": [
"</tag1>"
],
"fields": {
"first_name": {},
"mobile_number": {}
}
}
}
Using the above query we are able to fetch results but are not able to highlight the original field value as explained in the following link
Need to know if we are doing anything wrong or is there a bug
Please note that we have to use the Custom "_all" field as it is important to our requirement. Also, the datatype of the fields cannot be changed.
Thanks a lot
I've tested your query and it appears to me to highlight the original field, in this case mobile_number with tag fields surrounding it.
Here are the results I get:
I'm running the above query on version 6.6 of ElasticSearch. For version 5 the documentation shows a slightly different structure, can you try this: