Forums de discussion
highlight search results
Archi Madhu, modifié il y a 13 années.
highlight search results
Regular Member Publications: 237 Date d'inscription: 25/03/08 Publications récentes
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
Sandeep Nair, modifié il y a 13 années.
RE: highlight search results
Liferay Legend Publications: 1744 Date d'inscription: 06/11/08 Publications récentes
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
Archi Madhu, modifié il y a 13 années.
RE: highlight search results
Regular Member Publications: 237 Date d'inscription: 25/03/08 Publications récentesSandeep 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?
Sandeep Nair, modifié il y a 13 années.
RE: highlight search results
Liferay Legend Publications: 1744 Date d'inscription: 06/11/08 Publications récentes
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
CC Chang, modifié il y a 11 années.
RE: highlight search results
New Member Publications: 2 Date d'inscription: 21/06/12 Publications récentes
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 ?
CC Chang, modifié il y a 11 années.
RE: highlight search results
New Member Publications: 2 Date d'inscription: 21/06/12 Publications récentes
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();
}