Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to search documents other than published
I have an hook for the FileEntry indexer
public class MyFileEntryIndexerPostProcessor extends BaseIndexerPostProcessor {
@Override
public void postProcessContextQuery(BooleanQuery booleanQuery, SearchContext sc) throws Exception {
}
but I can't modify the booleanQuery object, removing unwanted clause on the status.... well, I can remove clauses from the collection (booleanQuery.clauses()) but it is useless, the underlying query doesn't change.
How can I modify the generated query?
Thanks, in advance,
Marco
I might be able to help with this one but I have a couple of questions.
1. When you say that they are able to search, do you mean they are searching in the control panel? or are they searching in the main site (using the search portlet)?
2. Are they using the search portlet or the web content search portlet?
Andrew Jardine:Hi Marco, I might be able to help with this one but I have a couple of questions. 1. When you say that they are able to search, do you mean they are searching in the control panel? or are they searching in the main site (using the search portlet)? 2. Are they using the search portlet or the web content search portlet?
Hi Andrew, sorry for the delay.... too much work and stuff to do!! :-)
My users are searching documents through the Search Portlet but, in the meantime, I solved my problem.
Here the solution, if it could help someone else...
Looking at the source code of the BaseIndexer I noted the method addStatus and the solution has come easily ;-)
protected void addStatus(BooleanQuery contextQuery, SearchContext searchContext) throws Exception {
....
if (<strong>status != WorkflowConstants.STATUS_ANY</strong>) {
contextQuery.addRequiredTerm(Field.STATUS, status);
} else {
BooleanQuery statusQuery = BooleanQueryFactoryUtil.create(searchContext);
statusQuery.addTerm(Field.STATUS, WorkflowConstants.STATUS_IN_TRASH);
contextQuery.add(statusQuery, BooleanClauseOccur.MUST_NOT);
}
Has been sufficient to insert Field.STATUS=WorkflowStatus.STATUS_ANY in the SearchContext in the main_search.jspf page
Indexer indexer = FacetedSearcher.getInstance(); if (specialUser) { searchContext.setAttribute(Field.STATUS, WorkflowConstants.STATUS_ANY); } Hits hits = indexer.search(searchContext);
and the Search Portlet now find all documents, as I need.
Anyway now I have a different problem :-) because the new documents are not indexed until they reach the Approved state so the question is: how to make a document get indexed just after it is inserted in the DL?
Regards,
Marco
Powered by Liferay™