我正在使用Spring Data Elastic Search在具有 Elastic Search 7.15的集群前面的 Spring Boot 中構建搜索服務。我正在突出顯示,但是我可以在檔案中看到在單獨的部分中回傳突出顯示的欄位的選項,如下所示:
"hits": [
{
"_index": "my-index-000001",
"_type": "_doc",
"_id": "1",
"_score": 1.6011951,
"_source": {
"message": "some message with the number 1",
"context": "bar"
},
"highlight": {
"message": [
" with the <em>number</em>",
" <em>1</em>"
]
}
}
]}
我想要的是在線回傳突出顯示的標簽,例如:
"hits": [
{
"_index": "my-index-000001",
"_type": "_doc",
"_id": "1",
"_score": 1.6011951,
"_source": {
"message": [
" with the <em>number</em>",
" <em>1</em>"
] ,
"context": "bar"
}
}
] }
是否有任何配置可以更改以在結果中回傳突出顯示的標簽?
uj5u.com熱心網友回復:
從檔案:
_source 欄位包含在索引時傳遞的原始 JSON 檔案正文。
Elasticsearch 不會回傳與_source傳入的內容不同的任何內容。老實說 - 我不明白您為什么要這樣做,您會在回傳的答案中丟失檔案中存盤的資訊。
除了回傳的亮點是一個字串陣列,其中的欄位_source是一個字串。應該如何將其映射到在message 屬性中需要 String 的物體?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/330902.html
標籤:弹性搜索
上一篇:通過IngressController公開ElasticAPM
下一篇:ES中的總數
