Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Corné Aussems
Global Search excluding userName term [UNANSWERED YET :)]
November 13, 2013 11:44 PM
Answer

Corné Aussems

Rank: Liferay Legend

Posts: 1270

Join Date: October 3, 2006

Recent Posts

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

 1+(
 2    +(companyId:10154)
 3    +(
 4        (
 5            +(entryClassName:com.liferay.portlet.journal.model.JournalArticle)
 6            +(status:0)
 7        )
 8    )
 9)
10+(   
11    *removed some lines for convenience*
12    content:aussems
13    userName:*aussems*
14    *removed some lines for convenience*
15)


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?
Vitaliy Koshelenko
RE: Global Search excluding userName term
November 12, 2013 1:10 PM
Answer

Vitaliy Koshelenko

Rank: Regular Member

Posts: 222

Join Date: March 25, 2011

Recent Posts

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.
Corné Aussems
RE: Global Search excluding userName term
November 13, 2013 3:43 AM
Answer

Corné Aussems

Rank: Liferay Legend

Posts: 1270

Join Date: October 3, 2006

Recent Posts

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. emoticon

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é
Suraj Bihari
RE: Global Search excluding userName term
November 13, 2013 2:22 PM
Answer

Suraj Bihari

Rank: Junior Member

Posts: 42

Join Date: May 20, 2011

Recent Posts

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
Corné Aussems
RE: Global Search excluding userName term
November 13, 2013 11:39 PM
Answer

Corné Aussems

Rank: Liferay Legend

Posts: 1270

Join Date: October 3, 2006

Recent Posts

Hey my dear Liferay friend Suraj,

Thanks for answering my post with an absolute ridicoulous suggestion emoticon
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
Suraj Bihari
RE: Global Search excluding userName term
November 14, 2013 12:19 PM
Answer

Suraj Bihari

Rank: Junior Member

Posts: 42

Join Date: May 20, 2011

Recent Posts

Namaste my dear Guru,

You're welcome emoticon 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 emoticon

Cheerio!