[英]Elasticsearch highlight doesn't highlight results
I'm testing ES and I would highlight the results of a query but it doesn't work with my simple query : 我正在测试ES,我将突出显示查询的结果,但不适用于我的简单查询:
var myQuery = {
"query": {
"bool": {
"must": {
"query_string": {
"query": mySearchText + "~3"
}
}
}
},
"highlight": {
"fields": {
"*":{}
}
}
};
Where did I made some mistake please ? 请问我在哪里弄错了? Thanks for all.
谢谢大家
PS : this is a sample of document PS:这是一个文档样本
{
"id_stage" : "3897",
"intitule_stage" : "Le surendettement des particuliers",
"objectifs" : "Acqu\u00e9rir les comp\u00e9tences suivantes :\r\n*Conna\u00eetre de mani\u00e8re approfondie les dispositions de la loi sur le surendettement des particuliers.\r\n*Ma\u00eetriser la proc\u00e9dure.",
"contenu" : "*Introduction :\r\n-D\u00e9finitions. Bilans chiffr\u00e9s. Statistiques.\r\n-La proc\u00e9dure de la Loi Borloo (juin 2003 et d\u00e9cret 2004) : le \"r\u00e9tablissement personnel\".\r\n-La loi Lagarde (juillet 2010) et ses d\u00e9crets d'application.\r\n-Pr\u00e9vention du surendettement.\r\n*Les conditions g\u00e9n\u00e9rales d'application de la proc\u00e9dure de surendettement :\r\n-Un d\u00e9biteur, personne physique de bonne foi.\r\n-Un \u00e9tat de surendettement.\r\n-Des dettes non professionnelles exigibles et \u00e0 \u00e9choir.\r\n*La proc\u00e9dure devant la commission de surendettement :\r\n-Ouverture, d\u00e9roulement et cl\u00f4ture de la proc\u00e9dure.\r\n*La proc\u00e9dure devant le juge de l'ex\u00e9cution :\r\n-Absence de contestation des mesures recommand\u00e9es par la commission de surendettement.\r\n-Contestation des mesures recommand\u00e9es par la commission.\r\n-Cons\u00e9quences de la force ex\u00e9cutoire.",
"pre_requis" : "",
"mmp" : "",
"sessions" : [{
"id_session" : "4775",
"debut" : "2016-11-29",
"date_fin" : "2016-12-02",
"ville" : "PARIS"
}
]
}
If you would like to highlight the relevant segments on all fields, you should use 如果您想突出显示所有字段中的相关细分,则应使用
"highlight": {
"fields": {
"_all":{}
}
}
Instead of 代替
"highlight": {
"fields": {
"*":{}
}
}
I am sure you must have solved this by now but for others facing the same issue, here is what I think you might have missed 我相信您现在一定已经解决了这个问题,但是对于其他面临相同问题的人,这是我认为您可能已经错过的事情
A field can only be used for highlighting if the original string value is available, either from the _source field or as a stored field.
如果原始字符串值可用于_source字段或作为存储字段,则该字段只能用于突出显示。
The _all field is not present in the _source field and it is not stored or enabled by default, and so cannot be highlighted.
_all字段不存在于_source字段中,并且默认情况下未存储或启用它,因此无法突出显示。 There are two options.
有两种选择。 Either store the _all field or highlight the original fields.
存储_all字段或突出显示原始字段。
http://nocf-www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html#highlighting-all-field http://nocf-www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html#highlighting-all-field
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.