Discussing Typesense Search Highlighting Capabilities
TLDR Jack enquiries about getting highlight data to include all fields in an object on Typesense. Jason clarifies that only specific fields in 'query_by' will be returned, which resolves the issue for Jack.
3
Sep 26, 2023 (2 months ago)
Jack
03:25 PM"tags": [
{ "key": "TagKey1", "value": "TagValue1" },
{ "key": "TagKey2", "value": "TagValue2" }
]
Searching for
TagValue1
gives me this highlight data:"highlight": {
"tags": [
{
"value": {
"matched_tokens": [ "TagValue1" ],
"snippet": "<mark>TagValue1</mark>"
}
},
{
"value": {
"matched_tokens": [],
"snippet": "TagValue2"
}
}
]
}
Is there a way to get the
key
for this matching field too? I can extract it from the document by using the index into the tags array, but I thought I had key
exposed at some point in the highlight data.Jack
03:26 PM{
"name": "things",
"enable_nested_fields": true,
"fields": [
{
"name": "tags.value",
"type": "string[]",
"optional": true
}
]
}
Jason
03:33 PMSo the access pattern typically is, you'd first check
highlight.field
for a display value and fall back to document.field
if it's not presentJack
03:34 PMkey
field (non-indexed) from the document then (using the positional index of the tag in the highlight data).1
Jason
03:34 PMJack
03:34 PMJason
03:34 PM1
Jack
03:35 PMJason
03:35 PMquery_by
which could be a subset of the indexed fieldsJack
03:35 PMtags.value
in my query_by
to just tags
makes it return the key! Is this expected (even though key
isn't indexed) or should I not depend on this behaviour?Jason
03:36 PMJason
03:37 PMJack
03:37 PMtags
to tags.value
at some point in my query_by
. The only indexed field in tags
is value
anyway, so I will switch it back to tags
. Appreciated!1
Typesense
Indexed 3011 threads (79% resolved)
Similar Threads
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.
Query on "weighted_score" & Issue with Synonym Highlighting
Stefan asked about "weighted_score" field and reported a possible synonym highlighting issue. Kishore Nallan clarified the use of "weighted_score". The possible synonym issue is still being investigated.
Querying and Indexing Multiple Elements Issues
Krish queried fields with multiple elements, which Kishore Nallan suggested checking `drop_tokens_threshold`. Krish wished to force OR mode for token, but Kishore Nallan admitted the feature was missing. Krish was able to resolve the issue with url encoding.
Troubleshooting Typo Highlighting in Search Queries
Stefan queried "chews" and "Roche", despite having a typo distance of 4, was highlighted. Kishore Nallan requested to test on v0.20 RC. Random results like "Sachets" and "Lachesca" were also highlighted. On single record query, highlighting works. Kishore Nallan assured to address this issue in the pending release.
Issues with Typesense Search and JSON Formatting
Babin had issues with not getting all fields in a search. The problem was due to a JSON formatting extension in VS Code. Jason also clarified the requirement of `query_by` in multi-search POST method.