Работа над Php и Elastic Search 6.5.2. Для тестового сценария я использовал почтальон: когда я применяю выделение, только обрезанный фрагмент контента, который соответствует предложению ключевого слова, отображается, когда я добавил два или более фрагмента под выделением. Я не хочу обрезать контент на уровне упругого поиска. Для этого я изменил количество фрагментов на ноль и получил ожидаемый результат в эластичном поиске, который дает весь контент, но когда я проверяю вывод в php приложении , весь контент становится жирным, когда соответствующее ключевое слово, существующее в поле URL.
Индекс:
PUT test/_doc/1
{
"title":"Apply For the admissions graduate and undergraduate"
"url":"https://someurl.com/admissions",
"content": "Engineers play an important role in almost every aspect of modern life. As an engineer in the 21st century, you’ll work in teams to develop ingenious ways to transform the world in which we live. Industrial engineers are in high demand in nearly every industry. Astounding innovations in semiconductor microelectronic engineering will continue to drive productivity and the economy by playing a key role in a wide range of technologies – information, communication, nanotechnology, defense, medicine, and energy.Admission into the microelectronic engineering program is competitive, but our admission process is a personal one. Each application is reviewed holistically for strength of academic preparation, performance on standardized tests, counselor recommendations, and your personal career interests. We seek applicants from a variety of geographical, social, cultural, economic, and ethnic backgrounds."
}
Запрос:
{
"query":{
"query_string":{
"fields":[
"content"
],
"query":"admissions"
}
},
"highlight":{
"fields":{
"title":{
"pre_tags":[
"<strong>"
],
"post_tags":[
"</strong>"
],
"number_of_fragments":3 //changed to 0 earlier
},
"content":{
"pre_tags":[
"<strong>"
],
"post_tags":[
"</strong>"
],
"fragment_size":150,
"number_of_fragments":3 //changed to 0 earlier
}
}
}
}
Результат:
"highlight": {
"content": [
"information, communication, nanotechnology, defense, medicine, and energy.Admission into the microelectronic engineering program is competitive, but our <strong>admission</strong>"
]
}