我们最近切换到 ElasticSearch Angular 版本,一切都按预期工作,除了突出显示,它根本没有返回。
这是我设置演示查询的方式:
$esClient.search({
index: 'myIndex',
body: {
size: 10,
from: 0,
query: query,
highlight: {
fields: {
"_all": { "pre_tags": ["<em>"], "post_tags": ["</em>"] }
}
}
}
}).then(function (result) {
// map the resultset for Row Template
var currentRows = result.hits.hits.map(function (record) {
return {
"type": record._type,
"entity": record._source, // the result
"highlight": record.highlight, // the highlights
"id": record._id // Search record ID
};
});
});
如果我使用与经典 XmlHttpRequest 相同的代码并传递包含突出显示的查询模型,我会返回一个 JSON,其中包含每个结果的突出显示数组,同时使用 ElasticSearch Angular 客户端查询成功但我没有找回亮点。
我做错了什么吗?
最佳答案
我认为您可能想更改为这种格式:
{
"query" : {...},
"highlight" : {
"pre_tags" : ["<tag1>"],
"post_tags" : ["</tag1>"],
"fields" : {
"_all" : {}
}
}}
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html
关于javascript - ElasticSearch Javascript,突出显示不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35315628/