0 Replies Latest reply on Nov 1, 2007 5:52 PM by jdelaney

    Extending search to search on properties (documentresultfilter)





      Sorry for the long post We have some custom document types that are simply extensions of normal documents but with extra properties such as a doctype property and so we want to be able to filter on these doctypes/properties.  I've already extended maindocuments and community actions pretty easily so that the user can filter the documents based on their type through the filter dropdown menu on community.ftl and main-documents.ftl by just adding some resultFilter.addProperty() calls in those actions.  But we also want to have this filtering ability on the main search page - so on search.ftl we added some additional checkboxes in "more options" menu for our custom doctype labels (the "documents" option will still return all documents including our custom ones as it does now since all our custom doctypes are still really just documents with a few extra properties). 



      So basically right now all I want is that if the user has checked one of our custom types on the search page, when they search, documents with that property will show up.  I know in SearchAction the results are retrieved through results = getQuery().getResults(loadResultTypes(), getStart(), getNumResults()).iterator(); but loadResultTypes() is a list of SearchQueryResult.ResultType objects and I do not want to add complexity of implementing that interface and/or DocumentType just for an extended property field on a document.  I also see in LocalQuery where lucene filters/multifilters are built up and added to the filtercache in retrieveDocumentFilters() but resultfilters/documentresultfilters are not inheriting from lucene filters and no wrapper exists it seems so doesn't seem like I could add a documentresultfilter anywhere there (would prefer not to anyways as I would like to keep everything scoped to the searchaction as much as possible).  But it also doesn't seem like there's any way to use a documentresultfilter in searchaction to limit the results at all.  The only way I've seen so far to possibly do this is overriding getResults() so that after it gets the results, to mimic what is done in the search.ftl and to iterate over the results:



      result = results.next();

      if (result.resultType.key == JiveConstants.DOCUMENT)                                        

      Document doc = jiveContext.getDocumentManager().getDocument(result.jiveContentObjectID);

      if (!doc.getProperties("doctype").equals(one of the doctype values the user checked)




      I would also have to do this in getResultCount() since the result count would be off because it would include documents that should be filtered out (or filtered in if we take out the "documents" checkbox and only allow our custom types to be searched on).



      Anyways, not a big fan of this approach since it's basically allowing extra work/operations to be done in the searching that ends up getting discarded.  Is there any way to integrate some type of DocumentResultFilter usage within the SearchAction (or elsewhere if it doesn't cause a big trickle-down effect of complexity) to filter/retrieve the documents in the search based on certain properties?  Or is the above approach where you simply get all the documents through the default search behavior, then just remove the ones you don't want the way to do this?  Or something else I'm missing that would be helpful?  Thanks for any insights.