Bert Godon Vor 10 Jahren 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(). Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Andrew Jardine Bert Godon Vor 7 Jahren 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? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Andrew Jardine Bert Godon Vor 7 Jahren 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? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Vanita Chawla Vor 10 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Muradali Hasan Vor 10 Jahren 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 Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ricardo Vieira Muradali Hasan Vor 7 Jahren Did you find an answer for this? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Ricardo Vieira Muradali Hasan Vor 7 Jahren Did you find an answer for this? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Justyna Gralinska Vor 10 Jahren 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" %><%@ Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Joseph Toman Vor 9 Jahren 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? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Giannis Foufas Vor 9 Jahren 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}); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Renata Willi Vor 9 Jahren 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? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Premysl Steidl Renata Willi Vor 7 Jahren Hi, did you find solution for this? I'm facing the same problem. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Premysl Steidl Renata Willi Vor 7 Jahren Hi, did you find solution for this? I'm facing the same problem. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen