Foren

highlight search results

thumbnail
Archi Madhu, geändert vor 13 Jahren.

highlight search results

Regular Member Beiträge: 237 Beitrittsdatum: 25.03.08 Neueste Beiträge
Hi All,

I want to highlight search words having HTML entities <sub>,&frac;,....

As we are using WYSIYWIG editor to create content they can use html entities like..

AT<sub>2</sub> and &frac12;


I want to highlight those words. but as they contain some special tags in between it is not searchable...

How can I search them?
Any idea?

Many Thanks,
Archi
thumbnail
Sandeep Nair, geändert vor 13 Jahren.

RE: highlight search results

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Hi,

Where do you want to use search? If you just want to search the text inside html for a particular value, then i think you can do it by stripping the Html and then searching. Like there is a method called HtmlUtil.stripHtml() which would strip the html.

Regards,
Sandeep
thumbnail
Archi Madhu, geändert vor 13 Jahren.

RE: highlight search results

Regular Member Beiträge: 237 Beitrittsdatum: 25.03.08 Neueste Beiträge
Sandeep Nair:
Hi,

Where do you want to use search? If you just want to search the text inside html for a particular value, then i think you can do it by stripping the Html and then searching. Like there is a method called HtmlUtil.stripHtml() which would strip the html.

Regards,
Sandeep



Sandeep,

I am already doing it...I am talking about sub/sup script like we have in word documents...
If we wrotr 2nd then it will automatically take 'nd' as super script and if you check code it ..in HTML it will be something like .. 2<sup>nd</sup>

I want to exactly search the way it is..how can I do that?

any Idea?
thumbnail
Sandeep Nair, geändert vor 13 Jahren.

RE: highlight search results

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Ok,

So in that case you have to use regex for example in case of sub, try using this pattern

(<sub>).*?(</sub>)


Regards,
Sandeep
CC Chang, geändert vor 11 Jahren.

RE: highlight search results

New Member Beiträge: 2 Beitrittsdatum: 21.06.12 Neueste Beiträge
I have another question. I am using search portlet in Liferay 6.1.1 CE. The search result summary is always shown from top part (about 200~300 bytes) of content. If the matched keyword is not inside the top part, the summary will be shown without any highlight keywords.
How do we make search result summary always include at least a matched keyword ?
CC Chang, geändert vor 11 Jahren.

RE: highlight search results

New Member Beiträge: 2 Beitrittsdatum: 21.06.12 Neueste Beiträge
I modified main_search_result_form.jsp to fix the requirement gap.
// AS-IS
if (assetRenderer != null) {
entryTitle = assetRenderer.getTitle(locale);
entrySummary = StringUtil.shorten(assetRenderer.getSummary(locale), 200);
}
// To-BE
if (assetRenderer != null) {
entryTitle = assetRenderer.getTitle(locale);
// entrySummary = StringUtil.shorten(assetRenderer.getSummary(locale), 200);
String snippet = document.get(Field.SNIPPET);
Summary summary = indexer.getSummary(document, locale, snippet, viewFullContentURL);
entrySummary = summary.getContent();
}