3
を強調使用する場合Elasticsearchが壊れたHTMLタグを返します。私は文字で強調表示された断片の大きさを制御するために"fragment_size" : 150
を使用しますが、それはして部分文字列を返します私はのように私は<em>コンテンツ</em>でのHTML文字列を持っている
"content": "<h3><a href=\"http://blog.local/page/%D8%A2%D8%B2%D8%A7%D8%AF\">The Matrix has you </a></h3>follow the white rabbit."
壊れたHTMLタグ:
"highlight": {
"content": [
"/%D8%A2%D8%B2%D8%A7%D8%AF">The <em>Matrix</em> has"
]
}
私はそれをJSONベースのクエリDSLで修正できますか?
{
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "matrix",
"fields": ["title","content"]
}
},
"filter": {
"term": { "content_type": "page" }
}
}
},
"highlight" : {
"order" : "score",
"fields" : {
"content" : {"fragment_size" : 150, "number_of_fragments" : 3}
}
}
}
そして、ここでサンプル応答です:
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.98773545,
"hits": [
{
"_index": "myindex",
"_type": "post",
"_id": "101",
"_score": 0.024953224,
"_source": {
"ID": 101,
"content_type": "page",
"date": "1999-02-18 14:32:21",
"title": "Wake up, Neo",
"content": "<h3><a href=\"http://blog.local/page/%D8%A2%D8%B2%D8%A7%D8%AF\">The Matrix has you </a></h3>follow the white rabbit."
},
"highlight": {
"content": [
"/%D8%A2%D8%B2%D8%A7%D8%AF">the <em>matrix</em> has"
]
}
}
]
}
}