Elasticsearch 多字段高亮字段返回json

{
    "took": 5,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 3,
            "relation": "eq"
        },
        "max_score": null,
        "hits": [
            {
                "_index": "test-1",
                "_type": "_doc",
                "_id": "5",
                "_score": null,
                "_source": {
                    "name": "flink开发编辑",
                    "createdate": "2021-09-09 10:32:19",
                    "id": "5",
                    "content": "flink开发"
                },
                "highlight": {
                    "name": [
                        "flink<span style='color:#29bf9d'>开发</span>编辑"
                    ],
                    "content": [
                        "flink<span style='color:#29bf9d'>开发</span>"
                    ]
                },
                "sort": [
                    "2021-09-09 10:32:19"
                ]
            },
            {
                "_index": "test-1",
                "_type": "_doc",
                "_id": "4",
                "_score": null,
                "_source": {
                    "name": "python开发编辑",
                    "createdate": "2021-09-08 21:19:19",
                    "id": "4",
                    "content": "python开发"
                },
                "highlight": {
                    "name": [
                        "python<span style='color:#29bf9d'>开发</span>编辑"
                    ],
                    "content": [
                        "python<span style='color:#29bf9d'>开发</span>"
                    ]
                },
                "sort": [
                    "2021-09-08 21:19:19"
                ]
            },
            {
                "_index": "test-1",
                "_type": "_doc",
                "_id": "3",
                "_score": null,
                "_source": {
                    "name": "Web开发Session超时设置",
                    "createdate": "2020-04-21 21:19:19",
                    "id": "3",
                    "content": "Web开发Session超时设置"
                },
                "highlight": {
                    "name": [
                        "Web<span style='color:#29bf9d'>开发</span>Session超时设置"
                    ],
                    "content": [
                        "Web<span style='color:#29bf9d'>开发</span>Session超时设置"
                    ]
                },
                "sort": [
                    "2020-04-21 21:19:19"
                ]
            }
        ]
    }
}
原文地址:https://www.cnblogs.com/Jeely/p/15263265.html