我是 Elasticsearch 的新手。我们有一些不同数据类型的数据要索引和检索。我们正在使用自定义“_all”字段,如下面的链接中所述
以下是我们的代码
用于创建索引
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"
}
}
}
}
}
添加到索引
PUT myindex/mytype/1
{
"first_name": "John",
"mobile_number": 9988776655
}
搜索
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": {}
}
}
}
使用上述查询,我们能够获取结果,但无法突出显示原始字段值,如以下链接中所述
需要知道我们是否做错了什么或是否有错误
请注意,我们必须使用自定义“_all”字段,因为它对我们的要求很重要。此外,不能更改字段的数据类型。
非常感谢