掲示板

highlight search results

thumbnail
13年前 に Archi Madhu によって更新されました。

highlight search results

Regular Member 投稿: 237 参加年月日: 08/03/25 最新の投稿
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
13年前 に Sandeep Nair によって更新されました。

RE: highlight search results

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
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
13年前 に Archi Madhu によって更新されました。

RE: highlight search results

Regular Member 投稿: 237 参加年月日: 08/03/25 最新の投稿
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
13年前 に Sandeep Nair によって更新されました。

RE: highlight search results

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
Ok,

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

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


Regards,
Sandeep
11年前 に CC Chang によって更新されました。

RE: highlight search results

New Member 投稿: 2 参加年月日: 12/06/21 最新の投稿
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 ?
11年前 に CC Chang によって更新されました。

RE: highlight search results

New Member 投稿: 2 参加年月日: 12/06/21 最新の投稿
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();
}