Bert Godon 10 年之前 Thanks for the quick response! It works great! But I have one little comment: there is no toString method on the BooleanClauseOccur object, but there is a getName method. I used BooleanClauseOccur.MUST.getName() instead of BooleanClauseOccur.SHOULD.toString(). 请登录以投票。 以……回复 取消 Andrew Jardine Bert Godon 7 年之前 This is a very important distinction! I just spent over an hour trying to do this same concept but allowing the user to select a DDMStructure that "MUST" be in place. I was using BooleanClauseOccur.MUST.toString() but it my query kept showing (+ddmStructureKey:xxxxx). As soon as I changed it to getName(), works like a charm. @Ray -- can you update the post for the next bugger like me that comes along and doesn't read the comments thread right away? 请登录以投票。 以……回复 取消
Andrew Jardine Bert Godon 7 年之前 This is a very important distinction! I just spent over an hour trying to do this same concept but allowing the user to select a DDMStructure that "MUST" be in place. I was using BooleanClauseOccur.MUST.toString() but it my query kept showing (+ddmStructureKey:xxxxx). As soon as I changed it to getName(), works like a charm. @Ray -- can you update the post for the next bugger like me that comes along and doesn't read the comments thread right away? 请登录以投票。 以……回复 取消
Vanita Chawla 10 年之前 Thanks for the blog article and your insight. It would be great if the search portlet could be configured from the portal-ext.properties or the control panel GUI at a global scope/context and per site basis. This requirement to configure search is recurring theme in our business requirements as we do more with Liferay every sprint. This global/site ability to configure search is critical for us as we embed the search portlet in the header in the theme and the search portlet instance configuration is not an option available to us. Even if we did not embed the portlet in the header, I can see value in being able to configure search globally or on a per site basis. . It would be great if this could be built into Liferay. In the meantime - is there anything we can do to do a support customization for the configuration of the search portlet? Couple of specific configuration examples I can think of are - restrict search scope to a specific site for a a site, disable user to show up in search, add active announcements to show up in search results. Thanks again. 请登录以投票。 以……回复 取消
Muradali Hasan 10 年之前 Thanks for nice information,I just want to know, if we want to include two or more extension for DLFileEntry How it can be done.I am trying using entryClassName:com.liferay.portlet.journal.model.JournalArticle (+entryClassName:com.liferay.portlet.documentlibrary.model.DLFileEntry +extension:pdf (+extension:doc))But it only search for pdf documents.My question is how can we include multiple extension of fileThanks 请登录以投票。 以……回复 取消 Ricardo Vieira Muradali Hasan 7 年之前 Did you find an answer for this? 请登录以投票。 以……回复 取消
Justyna Gralinska 10 年之前 For anyone interested in this functionality (just the core, not the configurable bit) but unclear on how to implement it- you need to create a new hook in eclipse and then:1. Add this code from to main_search .jspf somewhere above the search results table (html/portlet/search)Query stringQuery = StringQueryFactoryUtil.create("entryClassName:com.liferay.portlet.journal.model.JournalArticle (+entryClassName:com.liferay.portlet.documentlibrary.model.DLFileEntry +extension:pdf)");BooleanClause clause = BooleanClauseFactoryUtil.create(searchContext, stringQuery, BooleanClauseOccur.MUST.getName());searchContext.setBooleanClauses(new BooleanClause[] {clause});2. Declare the dependencies in init.jsp. i.e. add them to all the other dependencies at the top (html/portlet/search)page import="com.liferay.portal.kernel.search.SearchContext" %><%@page import="com.liferay.portal.kernel.search.BooleanClause" %><%@page import="com.liferay.portal.kernel.search.BooleanClauseFactoryUtil" %><%@page import="com.liferay.portal.kernel.search.BooleanClauseOccur" %><%@page import="com.liferay.portal.kernel.search.StringQueryFactoryUtil" %><%@page import="com.liferay.portal.kernel.search.Query" %><%@ 请登录以投票。 以……回复 取消
Joseph Toman 9 年之前 I'm glad to find something written about this API. Thanks! One follow up question:SearchContext has methods like setAssetTagNames and setAssetCategoryIds . How do the tags and categories specified there interact with the queries set with setBooleanClauses? ANDed? ORed? Overridden? 请登录以投票。 以……回复 取消
Giannis Foufas 9 年之前 Hello,Could you please complete the above code example?I would like to know how the searchContext is used to do the actual search.Regards,Query stringQuery = StringQueryFactoryUtil.create("entryClassName:com.liferay.portlet.journal.model.JournalArticle (+entryClassName:com.liferay.portlet.documentlibrary.model.DLFileEntry +extension:pdf)");BooleanClause clause = BooleanClauseFactoryUtil.create(searchContext, stringQuery, BooleanClauseOccur.SHOULD.toString());searchContext.setBooleanClauses(new BooleanClause[] {clause}); 请登录以投票。 以……回复 取消
Renata Willi 9 年之前 Thanks for this helpful article. The code works great. Only journal articles and pdf files are shown as search result, but it's not sorted according search relevance any more. All PDF files are listed at first and then all the journal articles. Why has the order changed? How can I sort it the other way round? 请登录以投票。 以……回复 取消 Premysl Steidl Renata Willi 7 年之前 Hi, did you find solution for this? I'm facing the same problem. 请登录以投票。 以……回复 取消
Premysl Steidl Renata Willi 7 年之前 Hi, did you find solution for this? I'm facing the same problem. 请登录以投票。 以……回复 取消