掲示板
highlight search results
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..
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
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 ½
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
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
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
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?
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
Regards,
Sandeep
So in that case you have to use regex for example in case of sub, try using this pattern
(<sub>).*?(</sub>)
Regards,
Sandeep
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 ?
How do we make search result summary always include at least a matched keyword ?
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();
}
// 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();
}