Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Global Search excluding userName term
Hi all,
From the Global Search Portlet i need to remove the searching (and results) for userName from the Global Search.
My aim is to do this without an EXT-plugin.
The LuceneImpl generates by default the following query
To remove the userName term i override JournalIndexer.java by registering this in my custom StartUpAction
and remove this specific line;
https://github.com/liferay/liferay-portal/blob/6.1.x/portal-impl/src/com/liferay/portlet/journal/util/JournalIndexer.java#L149
This works fine but to no avail, the problem here is that FacetedSearcher
https://github.com/liferay/liferay-portal/blob/6.1.x/portal-service/src/com/liferay/portal/kernel/search/FacetedSearcher.java#L166
Adds all Field.KEYWORDS including Field.USERNAME
https://github.com/liferay/liferay-portal/blob/6.1.x/portal-service/src/com/liferay/portal/kernel/search/Field.java#L70
Since we see only one 'userName' entry in the query i hoped i could overwrite userName with a dummy content, but LuceneHelper checks _includeIfUnique so that won't do it either.
Other idea was with an IndexerPostProcessor manipulating the collection of BooleanClauses inside the BooleanQuery. But
com.liferay.portal.kernel.search.BooleanClause does not support any useful method.
Anyone has some idea how to succeed or maybe suggests another solution path?
From the Global Search Portlet i need to remove the searching (and results) for userName from the Global Search.
My aim is to do this without an EXT-plugin.
The LuceneImpl generates by default the following query
+(
+(companyId:10154)
+(
(
+(entryClassName:com.liferay.portlet.journal.model.JournalArticle)
+(status:0)
)
)
)
+(
*removed some lines for convenience*
content:aussems
userName:*aussems*
*removed some lines for convenience*
)
To remove the userName term i override JournalIndexer.java by registering this in my custom StartUpAction
and remove this specific line;
https://github.com/liferay/liferay-portal/blob/6.1.x/portal-impl/src/com/liferay/portlet/journal/util/JournalIndexer.java#L149
This works fine but to no avail, the problem here is that FacetedSearcher
https://github.com/liferay/liferay-portal/blob/6.1.x/portal-service/src/com/liferay/portal/kernel/search/FacetedSearcher.java#L166
Adds all Field.KEYWORDS including Field.USERNAME
https://github.com/liferay/liferay-portal/blob/6.1.x/portal-service/src/com/liferay/portal/kernel/search/Field.java#L70
Since we see only one 'userName' entry in the query i hoped i could overwrite userName with a dummy content, but LuceneHelper checks _includeIfUnique so that won't do it either.
Other idea was with an IndexerPostProcessor manipulating the collection of BooleanClauses inside the BooleanQuery. But
com.liferay.portal.kernel.search.BooleanClause does not support any useful method.
Anyone has some idea how to succeed or maybe suggests another solution path?
You can just patch com.liferay.portal.kernel.search.Field class and remove Field.USER_NAME form it's KEYWORDS array in this case, and then put the complied class into ROOT/WEB-INF/classes directory.
Vitaliy Koshelenko:
You can just patch com.liferay.portal.kernel.search.Field class and remove Field.USER_NAME form it's KEYWORDS array in this case, and then put the complied class into ROOT/WEB-INF/classes directory.
Hi Vitaliy,
Thanks for your suggestion.
There is a good reason i do not want to use EXT-plugins .. maintainability !
So adding a compiled class to ROOT/WEB-INF/classes not a better option.

Since Liferay Core Developers and Gurus monitor unanswered post, would you please remove your answer for me so it get noticed.
Thanks again for your try.
Corné
Hi Corné,
You could configure the settings of the Global Search Portlet to leave out the User model.
Configure > Setup > Display Settings > Advanced > Search Configuration
{"facets": [
{
...
"data": {
"values": [
"com.liferay.portlet.bookmarks.model.BookmarksEntry",
"com.liferay.portlet.blogs.model.BlogsEntry",
"com.liferay.portlet.calendar.model.CalEvent",
"com.liferay.portlet.documentlibrary.model.DLFileEntry",
"com.liferay.portlet.journal.model.JournalArticle",
"com.liferay.portlet.messageboards.model.MBMessage",
"com.liferay.portlet.wiki.model.WikiPage",
"com.liferay.portal.model.User"
],
"frequencyThreshold": 1
...
Just remove the "com.liferay.portal.model.User" and no users are listed in the results.
Beste regards,
Suraj
You could configure the settings of the Global Search Portlet to leave out the User model.
Configure > Setup > Display Settings > Advanced > Search Configuration
{"facets": [
{
...
"data": {
"values": [
"com.liferay.portlet.bookmarks.model.BookmarksEntry",
"com.liferay.portlet.blogs.model.BlogsEntry",
"com.liferay.portlet.calendar.model.CalEvent",
"com.liferay.portlet.documentlibrary.model.DLFileEntry",
"com.liferay.portlet.journal.model.JournalArticle",
"com.liferay.portlet.messageboards.model.MBMessage",
"com.liferay.portlet.wiki.model.WikiPage",
],
"frequencyThreshold": 1
...
Just remove the "com.liferay.portal.model.User" and no users are listed in the results.
Beste regards,
Suraj
Hey my dear Liferay friend Suraj,
Thanks for answering my post with an absolute ridicoulous suggestion
Its not about finding Users, its about not finding lucene documents eg JournalAticle, DLFileEntry , Blogs .. by its creator.
As you can read in the post, By default the indexed document is containing userName and by default userName is a term that is searched for.
Zum beispiel. search for 'suraj bihari' with the users disabled as you suggest ;)
Missed you at the DevCon ;)
C.heers
Thanks for answering my post with an absolute ridicoulous suggestion

Its not about finding Users, its about not finding lucene documents eg JournalAticle, DLFileEntry , Blogs .. by its creator.
As you can read in the post, By default the indexed document is containing userName and by default userName is a term that is searched for.
Zum beispiel. search for 'suraj bihari' with the users disabled as you suggest ;)
Missed you at the DevCon ;)
C.heers
Namaste my dear Guru,
You're welcome
I was a bit over enthusiastic suggesting 'another solution' path...
It has been a while, from now on, I'll try to attend the next event and post accurate solutions
Cheerio!
You're welcome

It has been a while, from now on, I'll try to attend the next event and post accurate solutions

Cheerio!
Hi,
Any idea how to achieve this on Liferay 7.1
Regards,
Arun
Corné Aussems:
its about not finding lucene documents eg JournalAticle, DLFileEntry , Blogs .. by its creator.
Any idea how to achieve this on Liferay 7.1
Regards,
Arun
Hi ,
Any idea how to achieve this on Liferay 7.0 DXP. Is this issue has a solution?
Please update me the solution ASAP.
Thanks,Mohammed Imtiaz H.
Any idea how to achieve this on Liferay 7.0 DXP. Is this issue has a solution?
Please update me the solution ASAP.
Thanks,Mohammed Imtiaz H.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™