Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Tag & search lfr user [RESOLVED] Rishi Dev Gupta April 28, 2009 6:01 AM
RE: Tag & search lfr user Victor Zorin April 21, 2009 8:43 PM
RE: Tag & search lfr user Rishi Dev Gupta April 21, 2009 9:14 PM
RE: Tag & search lfr user Rishi Dev Gupta April 22, 2009 4:01 AM
RE: Tag & search lfr user Victor Zorin April 22, 2009 12:39 PM
RE: Tag & search lfr user Rishi Dev Gupta April 24, 2009 2:14 AM
RE: Tag & search lfr user Victor Zorin April 24, 2009 3:22 AM
RE: Tag & search lfr user Rishi Dev Gupta April 26, 2009 2:57 AM
RE: Tag & search lfr user Rishi Dev Gupta April 28, 2009 5:56 AM
RE: Tag & search lfr user Victor Zorin April 28, 2009 1:49 PM
RE: Tag & search lfr user Chris Whittle July 21, 2009 5:52 AM
RE: Tag & search lfr user Victor Zorin July 21, 2009 3:36 PM
RE: Tag & search lfr user Chris Whittle July 22, 2009 5:22 AM
RE: Tag & search lfr user Victor Zorin July 22, 2009 2:55 PM
RE: Tag & search lfr user Chris Whittle July 23, 2009 8:04 AM
RE: Tag & search lfr user Victor Zorin July 23, 2009 9:04 PM
RE: Tag & search lfr user Chris Whittle July 24, 2009 4:47 AM
RE: Tag & search lfr user inTest inTest inTest September 3, 2009 5:16 AM
RE: Tag & search lfr user Namrata Hangal February 7, 2011 10:06 PM
RE: Tag & search lfr user Krati Gupta February 16, 2011 11:44 PM
RE: Tag & search lfr user Namrata Hangal February 17, 2011 2:07 AM
RE: Tag & search lfr user Krati Gupta February 17, 2011 2:15 AM
RE: Tag & search lfr user Namrata Hangal February 17, 2011 4:54 AM
RE: Tag & search lfr user Amit Shukla October 16, 2012 10:34 PM
RE: Tag & search lfr user Amit Shukla October 17, 2012 10:16 PM
Rishi Dev Gupta
Tag & search lfr user [RESOLVED]
April 28, 2009 6:01 AM
Answer

Rishi Dev Gupta

Rank: Expert

Posts: 252

Join Date: November 23, 2008

Recent Posts

Hi all

I have a requirement where i need the functionality to be able to set tags against the liferay user (which the team is able to do so). Now using the default Search portlet I need that user should not only be search able through name but also the tags associated with him/her.

The functionality should look same as we given by liferay wiki or blogs or journal content.

Does anybody have idea how to go for searching the user based on tags?

Thanks
Rishi
Victor Zorin
RE: Tag & search lfr user
April 21, 2009 8:43 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

To override user search procedures, make your own class my modifying com.liferay.portlet.directory.util.DirectoryOpenSearchImpl class which is in portal-impl pack.
After that, change <open-search-class> entry for portlet 11 in liferay-portlet.xml. After portal restart, your own class will be used by Tools->Search portlet.

Up to version 5.1+, unlike wiki and blogs and others, directory search is not implemented using lucene, but via direct sql queries. If it was lucene, the applied change would be absolutely minimal and quick.

From 5.2, it has started using indexing engine, for details see class com.liferay.portal.service.impl.UserLocalServiceImpl (look for Hits word). You can take this search(...) method and incorporate it directly within your open-search-class. Do not forget to add another line that would include tag-based search:
searchQuery.addTerm(com.liferay.portal.kernel.search.Field.TAGS_ENTRIES, keywords);
Rishi Dev Gupta
RE: Tag & search lfr user
April 21, 2009 9:14 PM
Answer

Rishi Dev Gupta

Rank: Expert

Posts: 252

Join Date: November 23, 2008

Recent Posts

Thanks Victor

I am using LFR 5.2.1 with mysql on jre 6 platform.

Till now what I tried out is making a copy of UserLocalServiceImpl.java in ext enviornment with same package as in source and adding the following code in search method

1
2                        if (Validator.isNotNull(firstName)) {
3                searchQuery.addTerm(Field.TAGS_ENTRIES, firstName);
4                System.out.println("-----0"+firstName);
5               
6            }


Also kept the search class entry in liferay-portlet.xml the same way as it was orginal.

What I tried to do above is I want to override the implementation of search method. But it didn't worked.

Now I am going your way, making the custom class and adding it to the xml.
Rishi Dev Gupta
RE: Tag & search lfr user
April 22, 2009 4:01 AM
Answer

Rishi Dev Gupta

Rank: Expert

Posts: 252

Join Date: November 23, 2008

Recent Posts

Not successfull till now

What i have done is


1. I have created a class com.liferay.portlet.user.UserOpenSearchImpl.java file in ext-impl

 1
 2public class UserOpenSearchImpl extends HitsOpenSearchImpl {
 3   
 4    public static final String SEARCH_PATH = "/c/directory/open_search";
 5
 6    public static final String TITLE = "Liferay Directory Search: ";
 7   
 8    public Hits getHits(long companyId, String keywords, int start, int end) throws Exception {
 9        return UserLocalServiceUtil.search(
10            companyId, keywords, true, null, start, end, new com.liferay.portal.kernel.search.Sort() );
11    }
12   
13    public String getSearchPath() {
14        return SEARCH_PATH;
15    }
16   
17    public String getTitle(String keywords) {
18        return TITLE + keywords;
19    }
20        private static Log _log =
21             LogFactoryUtil.getLog(UserOpenSearchImpl.class);
22       
23}



and replace the entry in portlet 11 in liferay-portelt.xml with this one

1<open-search-class>com.liferay.portlet.user.UserOpenSearchImpl</open-search-class>



Now i have copied the com.liferay.portal.service.impl.UserLocalServiceImpl and added the below code to search method
1 searchQuery.addTerm(Field.TAGS_ENTRIES, firstName, true);




But the thing is I am not getting any results for tag based search

I can get the search working by user details like first name, middlename, suranme, screen name but not by tag added against user.

Do we have to make the entries of tag in lucene also, as this search is based on lucene.
Victor Zorin
RE: Tag & search lfr user
April 22, 2009 12:39 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

1. Can you make sure that within lucene users have tag values. For verifying this, print out lucene records as described below:
 1
 2            for (int i = 0; i < hits.getDocs().length; i++) {
 3                com.liferay.portal.kernel.search.Document doc = hits.doc(i);
 4
 5                java.util.Iterator<com.liferay.portal.kernel.search.Field> it = doc
 6                        .getFields().values().iterator();
 7                while (it.hasNext()) {
 8                    com.liferay.portal.kernel.search.Field field = it.next();
 9                    logger.info(field.getName() + "=" + field.getValue());
10                }
11                                                             }

2. In your code it looks like you search for lucene entries that have tags that are first names,
1searchQuery.addTerm(Field.TAGS_ENTRIES, firstName, true);
Is this what you expect? Or you need to addTerm(TAGS_ENTRIES, keywords).
3. Another note, from your <open-search-class> I would not be calling UserLocalServiceUtil.search(...), but instead inserted lucene code into it. This way you would not have to modify core UserLocalServiceUtil class.
Rishi Dev Gupta
RE: Tag & search lfr user
April 24, 2009 2:14 AM
Answer

Rishi Dev Gupta

Rank: Expert

Posts: 252

Join Date: November 23, 2008

Recent Posts

Hi Victor

1. I have tried your code but for hits but it is coming empty means that my search is not working as it should be on user.

2. Its the same thing as using "keywords" as all the user properties like firstname, surname, middlename etc are assigned the value of "keyword" variable. So it does not matter much here.

3. I haven't checked out the lucene code yet, Can you tell me where I can find one.


Also the issue is when LFR hasn't provided the tag based search on user like we have with wiki or blogs, so there won't be any implementation in LFR source to find user using tags through lucene as I think currently the code won't be making any entries to lucene.

What my team mate did for tagging user is, he used the tag library
1liferay-ui:tags-selector
and invoked the
1com.liferay.portlet.tags.service.impl.TagsEntryLocalServiceImpl
2 checkEntries(long userId, long groupId, String[] names)


So is the right approach to make entries in database and make it searchable through lucene.
Victor Zorin
RE: Tag & search lfr user
April 24, 2009 3:22 AM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

Rishi, I'll post one of my classes, that I am using for own Global Search Portlet. have a look. It is not searching for User but for any entry, that has been submitted by given portletIds in a given set of cumminity Ids. Code is below, see if it makes sense to you. I do not think that it is going to be very much different for Users:
 1
 2    public Hits search(long companyId, String[] portletIds, long groupIds[],
 3            String keywords, SearchConfigForm configForm, int start, int end)
 4            throws SystemException {
 5
 6        try {
 7            BooleanQuery contextQuery = BooleanQueryFactoryUtil.create();
 8            if (portletIds.length > 0) {
 9                BooleanQuery portletIdsQuery = BooleanQueryFactoryUtil.create();
10                for (int i = 0; i < portletIds.length; i++) {
11                    TermQuery termQuery = TermQueryFactoryUtil.create(
12                            "portletId", portletIds[i]);
13
14                    portletIdsQuery.add(termQuery, BooleanClauseOccur.SHOULD);
15                }
16                contextQuery.add(portletIdsQuery, BooleanClauseOccur.MUST);
17            }
18
19            if (groupIds.length > 0) {
20                BooleanQuery groupIdsQuery = BooleanQueryFactoryUtil.create();
21
22                for (long groupId : groupIds) {
23                    TermQuery termQuery = TermQueryFactoryUtil.create(
24                            "groupId", groupId);
25
26                    groupIdsQuery.add(termQuery, BooleanClauseOccur.SHOULD);
27                }
28
29                contextQuery.add(groupIdsQuery, BooleanClauseOccur.MUST);
30            }
31
32            BooleanQuery searchQuery = BooleanQueryFactoryUtil.create();
33
34            if (Validator.isNotNull(keywords)) {
35                if (configForm.getSearchByTitle()) {
36                    searchQuery.addTerm(Field.TITLE, keywords);
37                }
38                if (configForm.getSearchByContent()) {
39                    searchQuery.addTerm(Field.CONTENT, keywords);
40                }
41                searchQuery.addTerm(Field.PROPERTIES, keywords);
42                searchQuery.addTerm(Field.TAGS_ENTRIES, keywords);
43            }
44
45            BooleanQuery fullQuery = BooleanQueryFactoryUtil.create();
46
47            fullQuery.add(contextQuery, BooleanClauseOccur.MUST);
48
49            if (searchQuery.clauses().size() > 0) {
50                fullQuery.add(searchQuery, BooleanClauseOccur.MUST);
51            }
52            //logger.info("all fullQuery=" + fullQuery.toString());
53            Sort[] sorts = new Sort[1];
54            Sort sort = new Sort();
55            sort.setFieldName("score");
56            sort.setType(Sort.SCORE_TYPE);
57            sort.setReverse(false);
58            sorts[0] = sort;
59            Hits hits = SearchEngineUtil.search(companyId, fullQuery, sorts,
60                    start, end);
61            //Hits hits = SearchEngineUtil.search(companyId, fullQuery, start, end);
62            //logger.info("all found hits " + hits.getLength());
63            return hits;
64        } catch (Exception e) {
65            logger.error("error " + e.getMessage());
66            return null;
67        }
68    }


Edited: try to run it using Directory portlet Id, attempt to fetch at least one user and print all document attributes as in previous messages. I am not sure whether you have users with tag attributes as well, as never tried it myself.
Rishi Dev Gupta
RE: Tag & search lfr user
April 26, 2009 2:57 AM
Answer

Rishi Dev Gupta

Rank: Expert

Posts: 252

Join Date: November 23, 2008

Recent Posts

Victor,
I have tried using the code posted by you above, Infact its almost the same code that I have implemented keeping Wiki portlet search as base. I have tried it using with 2 different portlet ids --> Directory-11, Enterprise Admin user-125 (used currently by directory open search class) but not able to retrieve any results.

Findings

1. I was further looking into search and found the com.liferay.portlet.enterpriseadmin.util.UserIndexer.java class. When I looked for its references in lfr source, its called every time the user object is added/edited/deleted.

2. When I compared the com.liferay.portlet.wiki.util.Indexer.java for wiki portlet with UserIndexer.java, I found that they are nowhere refer to tag entries class/table. Thus I want to know is the indexer class playing any role while we search for any entity in lfr. If yes then seeing the user indexing code it means that currently the user search does not accommodate searching based on tags whether we make entries in lfr table
tagsentry/tagsasset (as I have done) or pass the tag entry criteria in out search code (as told by you).

3. If the above is true can anybody please specify what exact steps I need to work out to make the LFR user searchable through tags also.


Rishi
Rishi Dev Gupta
RE: Tag & search lfr user
April 28, 2009 5:56 AM
Answer

Rishi Dev Gupta

Rank: Expert

Posts: 252

Join Date: November 23, 2008

Recent Posts

I am able to get it working now.
As mentioned in my last post I was heading in the right direction.

1. Currently there is no tag based lucene search implemented in liferay. So what I did is I made changes in the Indexer class for user, so that the user tag information is indexed along with other user details.

2. Implemented the search query code which will search for tags using the criteria key Field.TAGS_ENTRIES
and it worked fine.
Victor Zorin
RE: Tag & search lfr user
April 28, 2009 1:49 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

Excellent.
In this case, non-existence of tags for users was always the primary suspect. So, when someone builds a specialized search query, it is important to be able to print out lucene doc attributes and check which attributes are indexed and what are the values of those attributes.

It is also worthwhile to mention that, in the past, lucene attribute set was changing between portal releases. Make sure that you review your custom lucene queries when upgrading to newer LR versions.
Chris Whittle
RE: Tag & search lfr user
July 21, 2009 5:52 AM
Answer

Chris Whittle

Rank: Expert

Posts: 462

Join Date: September 17, 2008

Recent Posts

Victor is it possible to change the search portlet to only look at the community they are in? Due to the permission holes in the current search of the Enterprise editions we need to limit have tried to implement the permission changes that are in the non EE versions but it's causing issues and so I'm looking at other options.... Thanks Whitt
Victor Zorin
RE: Tag & search lfr user
July 21, 2009 3:36 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

Chris, it should not be the problem. Which one of EEs are you using? Which part did you try to apply the changes in?
Generally, it is important to pass groupId otherwise you will get access to data across all communities.. I remember Parul did similar changes, have a look at her threads.
Chris Whittle
RE: Tag & search lfr user
July 22, 2009 5:22 AM
Answer

Chris Whittle

Rank: Expert

Posts: 462

Join Date: September 17, 2008

Recent Posts

I ended up getting it to work for everything except Directory (which we deactivated) here is my code for the next person who needs it... The next step is to get non-permissioned results to not show in the list.. With Brunos help we tried to backport the ones from the latest community edition but had stability issues so I had to back them out... Victor or anyone do you have a solution for hiding content you don't have access to in searches? my early version was a JSP version but it screwed up pagnation and counts... Oh yeah we're using 5.1.5EE
Attachments: communitylimited.zip (36.7k)
Victor Zorin
RE: Tag & search lfr user
July 22, 2009 2:55 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

Victor or anyone do you have a solution for hiding content ...

Hiding on rendering level is not going to help here, the displayed result will not correlate with the common statistics data that is also displayed. (As I mentioned before, check Parul posts). Patching is required at lucene query level, but liferay methods do not allow for the direct propagation of additional parameters, that are required for the enforcement of proper permisssioning.
To share own experience, a couple of years ago we decided to take search result delivery into own hands. No regrets so far as this is one of the primary functions in corporate environments. It gave clients true group-wise search capability and plenty of configuration freedom at no extra cost. For us, it has opened a door wide for a range of enhancements, such as corporate network search (no need to do uploading any more), search query and search action logging and analysis. Some absolutely stunning discoveries are made when such analysis is presented to marketing. Having own search has also allowed us to kick-off the development of a suggestive framework, similar to google/yahoo/facebook, but across all portal facilities.
Chris Whittle
RE: Tag & search lfr user
July 23, 2009 8:04 AM
Answer

Chris Whittle

Rank: Expert

Posts: 462

Join Date: September 17, 2008

Recent Posts

Victor, What do you think about this? http://www.liferay.com/web/guest/community/forums/-/message_boards/message/1609212 here is my first attempt to do permission and control them from the jsp but that of course breaks pagnation... What if i moved the looping through the hits to the newly customized OpenSearchImpl java files so it only returns the hits filtered by permissions....
Victor Zorin
RE: Tag & search lfr user
July 23, 2009 9:04 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

Had a look ...

Question 1: do you really need to use roles' level for limiting your search, or group-based membership will satisfy your requirements?
Question 2: Are you using 'overall' search portlet or specific ones, such as doclib, webcontent, etc ? They have different implementation paths and classes.
Chris Whittle
RE: Tag & search lfr user
July 24, 2009 4:47 AM
Answer

Chris Whittle

Rank: Expert

Posts: 462

Join Date: September 17, 2008

Recent Posts

1) Because the users are controlling the permissions and they are all role based I have to stick with that...
2) Both... I found out yesterday that the portlets are using a little different and so I am changing the search.jsp for each of the content portlets to use the new OpenSearchImpl I've created...

I know it's not the best but we currently don't have any better options...
I'm about done I'll post it sometime today and see what you think....
inTest inTest inTest
RE: Tag & search lfr user
September 3, 2009 5:16 AM
Answer

inTest inTest inTest

Rank: New Member

Posts: 5

Join Date: September 1, 2009

Recent Posts

Hello,
I'm new to LFR, so excuse me if the question is trivial.
I what to add the filtering by tag functionality to web content portlet.
As I understand it might be also not implemented. Am I wrong? Any suggestions how to implemnt?
Thanks,
beginer
Namrata Hangal
RE: Tag & search lfr user
February 7, 2011 10:06 PM
Answer

Namrata Hangal

Rank: Regular Member

Posts: 161

Join Date: July 26, 2010

Recent Posts

Hi all,

I'm looking for a customized search that can filter documents/ content based on title, date of creation, author, content type and keywords.

I understand that title and keyword based search is already a part of the Search portlet (federated search). But, what needs to be done to include the other filters in the search?

I'm a beginner, so, a detailed documentation would be more helpful to me.

Appreciate any help.

Regards,
Namrata
Krati Gupta
RE: Tag & search lfr user
February 16, 2011 11:44 PM
Answer

Krati Gupta

Rank: Regular Member

Posts: 113

Join Date: December 5, 2008

Recent Posts

HI All,

I have a requirement like that , I have add extra field in Directory portlet as I want to search user from custom attribute Location apart from user first name , middle name ,last name , screen name and email address.

Now please tell what all files need to be changed for searching user from custom attribute Location .

Please help as soon as possible it is on urgent basis.
Namrata Hangal
RE: Tag & search lfr user
February 17, 2011 2:07 AM
Answer

Namrata Hangal

Rank: Regular Member

Posts: 161

Join Date: July 26, 2010

Recent Posts

Hi Krati,

I am not too sure, but I guess you will have to check the Directory model structure first..

Regards,
Namrata
Krati Gupta
RE: Tag & search lfr user
February 17, 2011 2:15 AM
Answer

Krati Gupta

Rank: Regular Member

Posts: 113

Join Date: December 5, 2008

Recent Posts

Hi Namrata,

I had checked the structure , but unable to figure out what code and in which file it need to changed .
Namrata Hangal
RE: Tag & search lfr user
February 17, 2011 4:54 AM
Answer

Namrata Hangal

Rank: Regular Member

Posts: 161

Join Date: July 26, 2010

Recent Posts

Hi Krati,

Being new myself (I'm sure you may have noticed emoticon ), I can't help you much, because I am myself looking into customization of Document Library Search.

But for a start, I would suggest you download the liferay source, if you haven't already.

You could check liferay_portal_home/tomcat/root/html/portlets/directory and check out all the files there. I usually start with view.jsp.

After that, in the source code, you can check portal-impl,service,util/src/com/liferay/portal (& portlet)/directory and try to find missing links.

The search implementation is I think the DirectoryOpenSearchImpl.java, not sure again!

Just trying to help someone who's in a similar situation as myself!

Regards,
Namrata
Amit Shukla
RE: Tag & search lfr user
October 16, 2012 10:34 PM
Answer

Amit Shukla

Rank: Junior Member

Posts: 92

Join Date: June 7, 2012

Recent Posts

Hi all,
I am looking customization for document library search.

I have added a dialog (-->Advance search) in View,jsp (original core of life ray) and on click of this dialog a form will open as a pop Up. This pop up form has conatains

custom attributes names and their values as drop down . after selection of custom attributes values user click on search button and now i want to display result of search.

for this a am writing a ext plugin .First part is working means on click of advance search -----a pop up form will open but on click of pop up form submit button --nothing is happen (means action is not working )
I have written following class
View.jsp--(liferay core's modified by me)
advance search .jsp-----(for the pop up forms)
advanceresource _search .jsp---(paralel tp serach_resource.jsp of liferay core)
advancesearchactiob,java---( customized class)
Strusts-config-ext.xml
tile-def.xml
Plesae any body help me . or tell me better way to do this task..







Please any one have idea about that.

Thanks
Amit
Amit Shukla
RE: Tag & search lfr user
October 17, 2012 10:16 PM
Answer

Amit Shukla

Rank: Junior Member

Posts: 92

Join Date: June 7, 2012

Recent Posts

Hi Namrta,

I am trying for customization of Document Library Search.Can you guide me how should I approach this?

Thanks
Amit Shukla