Fórum

highlight search results

thumbnail
Archi Madhu, modificado 13 Anos atrás.

highlight search results

Regular Member Postagens: 237 Data de Entrada: 25/03/08 Postagens Recentes
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, modificado 13 Anos atrás.

RE: highlight search results

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
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, modificado 13 Anos atrás.

RE: highlight search results

Regular Member Postagens: 237 Data de Entrada: 25/03/08 Postagens Recentes
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, modificado 13 Anos atrás.

RE: highlight search results

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
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, modificado 11 Anos atrás.

RE: highlight search results

New Member Postagens: 2 Data de Entrada: 21/06/12 Postagens Recentes
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, modificado 11 Anos atrás.

RE: highlight search results

New Member Postagens: 2 Data de Entrada: 21/06/12 Postagens Recentes
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();
}