#community-help

Issues with Document Highlighting in API Endpoint

TLDR anuser had issues with highlighting snippets in document posted to Wah collection. Kishore Nallan suggested using highlight_full_fields for complete text highlights.

Powered by Struct AI
2
3mo
Solved
Join the chat
Jul 07, 2023 (3 months ago)
anuser
Photo of md5-63680f493f486b6022d9f679d5f9279a
anuser
10:55 PM
hello i want to ask
I've created it and I'm using the documents endpoint to post new documents to the Wah collection
req body {
  "id" : "2",
  "page" : 10,
  "book" : "p1W" ,
  "text": "yes yes no lol yes"
}

then I get it with the endpoint search?q=yes and I get a snippet like this "<mark>yes</mark> <mark>yes</mark>no lol <mark>yes</mark>"

then I post a new document with data like below:

 {
  "id" : "1",
  "page" : 10,
  "book" : "p1W" ,
  "text": "<h1>B. Memperbaiki Niat</h1><strong>1. iyakah Dalam Menimba Ilmu</strong><q>iyakah, Berniat baik dalam menimba ilmu yaitu dengan bermaksud untuk mendapatkan ridha Allah ta'ala, beramal atas dasar ilmu, menghidupkan syariah, menyinari hatinya, menghiasi batinnya, mendekatkan diri kepada Allah ta'ala pada hari kiamat dan meraih terhadap apa yang telah Allah siapkan untuk orang berilmu berupa ridhaNya serta kebesaran karuniaNya.</q><strong>2. iyakah Imam Ats-Tsauri</strong><q>Sufyan ats-Tsauri berkata: "tidaklah aku memperbaiki sesuatu yang lebih berat bagiku daripada niatku"</q>"
}. 

but why when I get the data from the search endpoint? q=iyakah I get the snippet results "h1&gt;B. Memperbaiki Niat&lt;/h1&gt;&lt;strong&gt;1. &lt;mark&gt;iyakah&lt;/mark&gt; Dalam Menimba Ilmu&lt;/strong&gt;&lt;q&gt;iyakah, Berniat". even though the text above has more than 1 word iyakah, but what is highlighted is only 1 word iyakah.
Jul 08, 2023 (3 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:05 AM
You can use highlight_full_fields if you want the whole text to be highlighted. We offer both snippet highlighting and full field highlighting.