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 (32 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 3015 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.
Trouble in Implementing Deeply Nested Search
Anirudh is struggling to implement a two-level nested search. Jason asked for some specific examples to study the issue. Anirudh provided some material, realizing that adding top fields helped but might over-index. Jason then suggested reporting this issue on GitHub.
Issues with Displaying Paragraphs Using Typesense and React-instantsearch
Mark is struggling with displaying only relevant paragraphs of indexed body text in a UI with react-instantsearch and Typesense. Jason suggests modifications to the TypesenseInstantSearchAdapter instantiation, highlighting only relevant fields. The issue remains unresolved.
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.