svn merge -r 2570:2595 svn://www.alfresco.org/alfresco/BRANCHES/V1.2.0/root HEAD/root

svn merge -r 2597:2649 svn://www.alfresco.org/alfresco/BRANCHES/V1.2.0/root HEAD/root


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2650 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-04-12 14:58:21 +00:00
parent 0d45ce4c18
commit c88e18b6b7
9 changed files with 121 additions and 6 deletions

View File

@@ -686,8 +686,12 @@ public class AdvancedSearchBean
// then simply navigating to the browse screen will cause it pickup the Search Context
SearchContext search = new SearchContext();
// set the full-text/name field value
search.setText(this.text);
// set whether to force AND operation on text terms
search.setForceAndTerms(Application.getClientConfig(FacesContext.getCurrentInstance()).getForceAndTerms());
if (this.mode.equals(MODE_ALL))
{
search.setMode(SearchContext.SEARCH_ALL);

View File

@@ -43,8 +43,10 @@ import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
@@ -679,9 +681,20 @@ public class BrowseBean implements IContextListener
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
results = this.searchService.query(
Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE, query, null, null);
// Limit search to the first 100 matches
SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(query);
sp.addStore(Repository.getStoreRef());
int searchLimit = Application.getClientConfig(FacesContext.getCurrentInstance()).getSearchMaxResults();
if(searchLimit > 0)
{
sp.setLimitBy(LimitBy.FINAL_SIZE);
sp.setLimit(searchLimit);
}
results = this.searchService.query(sp);
if (logger.isDebugEnabled())
logger.debug("Search results returned: " + results.length());

View File

@@ -119,6 +119,9 @@ public final class SearchContext implements Serializable
/** any additional fixed value attributes to add to the search, such as boolean or noderef */
private Map<QName, String> queryFixedValues = new HashMap<QName, String>(5, 1.0f);
/** set true to force the use of AND between text terms */
private boolean forceAndTerms = false;
/** logger */
private static Log logger = LogFactory.getLog(SearchContext.class);
@@ -217,6 +220,9 @@ public final class SearchContext implements Serializable
term = term.substring(1);
}
// special case for AND all terms if set (apply after operator character removed)
operatorAND = operatorAND | this.forceAndTerms;
if (term.length() != 0)
{
// operators such as AND and OR are only make sense for full text searching
@@ -654,6 +660,22 @@ public final class SearchContext implements Serializable
return this.queryFixedValues.get(qname);
}
/**
* @return Returns if AND is forced between text terms. False (OR terms) is the default.
*/
public boolean getForceAndTerms()
{
return this.forceAndTerms;
}
/**
* @param forceAndTerms Set true to force AND between text terms. Otherwise OR is the default.
*/
public void setForceAndTerms(boolean forceAndTerms)
{
this.forceAndTerms = forceAndTerms;
}
/**
* @return this SearchContext as XML
*