RE: Global Search excluding userName term

thumbnail
Corné Aussems, modified 11 Years ago. Liferay Legend Posts: 1313 Join Date: 10/3/06 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

+(
	+(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?
thumbnail
Vitaliy Koshelenko, modified 11 Years ago. Expert Posts: 319 Join Date: 3/25/11 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.
thumbnail
Corné Aussems, modified 11 Years ago. Liferay Legend Posts: 1313 Join Date: 10/3/06 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é
thumbnail
Suraj Bihari, modified 11 Years ago. Junior Member Posts: 41 Join Date: 5/20/11 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
thumbnail
Corné Aussems, modified 11 Years ago. Liferay Legend Posts: 1313 Join Date: 10/3/06 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
thumbnail
Suraj Bihari, modified 11 Years ago. Junior Member Posts: 41 Join Date: 5/20/11 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!
thumbnail
Arun Das, modified 6 Years ago. Regular Member Posts: 166 Join Date: 7/23/12 Recent Posts
Hi,

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
thumbnail
Imtiaz Mohammed H., modified 6 Years ago. New Member Posts: 7 Join Date: 8/3/15 Recent Posts
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.