#community-help

Issue with escapeHTML and Search Highlighting

TLDR Digamber is having trouble with the search highlighting not working when escapeHTML is set to false. Kishore Nallan and Jason try to help but the issue remains unresolved.

Powered by Struct AI
Dec 14, 2021 (25 months ago)
Digamber
Photo of md5-a0246423746b3b51425d05cfd9c494ae
Digamber
10:32 AM
My main issue is that whenever i set escapteHTML: false - the highlighting isn’t working
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:33 AM
Can you show a sample record and the response?
Digamber
Photo of md5-a0246423746b3b51425d05cfd9c494ae
Digamber
10:46 AM
instantSearch.addWidgets([
            searchBox({
                container: searchBoxEl[0],
                autofocus: true,
                placeholder: 'Search...',
                showSubmit: false,
                showReset: false,
            }),
            configure({
                hitsPerPage: config.per_page,
            }),
            hits({
                container: defaultSearchResultEl[0],
                escapeHTML: false,
                templates: {
                    item: `
      <h2>
        {{ __hitIndex }}:
        {{#helpers.highlight}}{ "attribute": "post_content" }{{/helpers.highlight}}
      </h2>
      <p>{{ post_description }}</p>
    `,
                },
            }),

        ]);
10:47
Digamber
10:47 AM
This is the code i used
10:47
Digamber
10:47 AM
the result is
10:48
Digamber
10:48 AM
10:49
Digamber
10:49 AM
Whereas if i set escapeHTML to false - it works as expected.
10:50
Digamber
10:50 AM
As you can see I need to escape html as the content is html
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:43 AM
Ok I will run this through another pair of eyes, for help.
Digamber
Photo of md5-a0246423746b3b51425d05cfd9c494ae
Digamber
11:47 AM
Thanks Kishore appreciate it
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:35 PM
Digamber could you try using JS instead of liquid like this and see if that helps: https://github.com/typesense/showcase-linux-commits-search/blob/82267196edc95f3f737af9d8374d0cf720892910/src/app.js#L191
Dec 15, 2021 (25 months ago)
Digamber
Photo of md5-a0246423746b3b51425d05cfd9c494ae
Digamber
04:21 AM
Jason no luck i’m still having the same issue
04:48
Digamber
04:48 AM
i had to strip the html before entry into document - for my use case it currenlty works - but was wondering if having html would be bennefitial

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

Troubleshooting Typesense Setup and Understanding Facets and Keywords

Demitri encountered errors when exploring Typesense for the first time. Jason guided them through troubleshooting and discussed facets, keyword settings, and widget configurations. Helin shared a Python demo app and its source code to help Demitri with their project.

1

56
21mo

Troubleshooting Issues with DocSearch Hits and Scraper Configuration

Rubai encountered issues with search result priorities and ellipsis. Jason helped debug the issue and suggested using different versions of typesense-docsearch.js, updating initialization parameters, and running the scraper on a Linux-based environment. The issues related to hits structure and scraper configuration were resolved.

7

131
8mo

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.

2

7
1mo

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.

6

111
8mo

Troubleshooting Local Scraper & Sitemap Issues

Rubai experienced issues with a local scraper and sitemap URLs not working. Jason instructed them to use meta tags and adjust their config file, which resolved the issues.

3

36
9mo