JavaScript Client's Return of Highlights Inquiry
TLDR Daniel questioned why the JavaScript client returned highlights in an array instead of an object. Kishore Nallan explained it was due to specific issues with statically typed languages needing defined JSON structures for parsing.
Jun 12, 2021 (27 months ago)
Daniel
11:19 AM"hits": [
{
"highlights": [
{
"field": "company_name",
"snippet": "<mark>Stark</mark> Industries"
}
],
"document": {
"id": "124",
"company_name": "Stark Industries",
"num_employees": 5215,
"country": "USA"
}
}
]
Would the highlights ever include more than one highlight per field?
"highlights": [
{
"field": "content",
"snippet": "<mark>Hawaii</mark> is the big wave island."
},
{
"field": "content",
"snippet": "for the <mark>Hawaii</mark> surf competition."
}
],
This makes the frontend code a lot more complex as you need to parse the array and see if the field matches:
PSEUDO CODE
temp = result.highlights.filter(el => {
if el.field === my-field-name
})
if temp.length === 0
// print highlight
// if temp.length > 1
// print first instance or list all highlights for this field
// else print document.content
However if the highlights was returned as an object it would be a lot easier on the frontend:
<p>{{ result.highlights.content ?? result.document.content }}</p>
Kishore Nallan
11:21 AMWhen you are querying multiple fields, each matching field is highlighted.
Daniel
11:22 AMKishore Nallan
11:23 AMDaniel
11:24 AM "hits": [
{
"highlights": {
"company_name": {
"snippet": "<mark>Stark</mark> Industries",
...
},
"content": {
"snippet": "<mark>Hawaii</mark> is the big wave island.",
...
},
},
"document": {
"id": "124",
"company_name": "Stark Industries",
"num_employees": 5215,
"country": "USA"
}
}
]
}
Kishore Nallan
11:24 AMfield_name -> highlight
Daniel
11:25 AMDaniel
11:26 AMKishore Nallan
11:26 AMKishore Nallan
11:26 AMKishore Nallan
11:27 AMKishore Nallan
11:28 AMDaniel
11:29 AM*Ho-oponopono*
in my documents so I’m quite impressed that Typesense finds it.Kishore Nallan
11:32 AMTypesense
Indexed 2764 threads (79% resolved)
Similar Threads
Merging Results of Multi-Search Queries: Workarounds and Future Features
Julian wanted to merge results from two similar collections. Kishore Nallan confirmed it's a feature that might be implemented but hasn't been prioritised. Both Julian and robert plan to use client-side solutions for now.
Resolving Typesense Result Issue in Document Collection Queries
Mike was encountering errors when searching for specific query in their Typesense document collection. Jason suggested it may be due to the `drop_tokens_threshold` setting. There was a misunderstanding but after further explanation from Jason, Mike understood and decided to continue the conversation via email.

Phrase Search Relevancy and Weights Fix
Jan reported an issue with phrase search relevancy using Typesense Instantsearch Adapter. The problem occurred when searching phrases with double quotes. The team identified the issue to be related to weights and implemented a fix, improving the search results.


Issues with Document Highlighting in API Endpoint
anuser had issues with highlighting snippets in document posted to Wah collection. Kishore Nallan suggested using `highlight_full_fields` for complete text highlights.
Issue with Search Duration on Typesense Database
Robert reported an issue about query time delay when adding a `filter_by` constraint in a large Typesense database. Kishore Nallan explained that this happens due to the order of operation and also promised to look into this issue further. Robert withdrew his interest in sponsoring the improvement due to moving from the project.