mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ML text index and search
Expose properties via DD Remove more old indexer code git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4592 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -170,6 +170,40 @@ public interface DictionaryService
|
||||
@NotAuditable
|
||||
PropertyDefinition getProperty(QName propertyName);
|
||||
|
||||
/**
|
||||
* Get all properties defined across all models with the given data type.
|
||||
*
|
||||
* Note that DataTypeDefinition.ANY will only match this type and can not be used as get all properties.
|
||||
*
|
||||
* If dataType is null then this method will return *ALL* properties regardless of data type.
|
||||
*
|
||||
* @param dataType
|
||||
* @return
|
||||
*/
|
||||
@NotAuditable
|
||||
Collection<QName> getAllProperties(QName dataType);
|
||||
|
||||
/**
|
||||
* Get all properties defined for the given model with the given data type.
|
||||
*
|
||||
* Note that DataTypeDefinition.ANY will only match this type and can not be used as get all properties.
|
||||
*
|
||||
* If dataType is null then this method will return *ALL* properties regardless of data type.
|
||||
*
|
||||
* @param dataType
|
||||
* @return
|
||||
*/
|
||||
@NotAuditable
|
||||
Collection<QName> getProperties(QName model, QName dataType);
|
||||
|
||||
/**
|
||||
* Get all poroperties for the specified model
|
||||
*
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
Collection<QName> getProperties(QName model);
|
||||
|
||||
/**
|
||||
* Gets the definition of the association as defined by its owning Class.
|
||||
*
|
||||
|
@@ -17,18 +17,18 @@
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.alfresco.repo.search.MLAnalysisMode;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
|
||||
/**
|
||||
* This class provides parameters to define a search.
|
||||
*
|
||||
* TODO
|
||||
* - paging of results page number and page size
|
||||
* - paging isolation - REPEATABLE READ, READ COMMITTED, may SEE ONCE tracking node refs in previous result sets
|
||||
* - how long repeatable read may be held
|
||||
* - limit by the number of permission evaluations
|
||||
* This class provides parameters to define a search. TODO - paging of results page number and page size - paging
|
||||
* isolation - REPEATABLE READ, READ COMMITTED, may SEE ONCE tracking node refs in previous result sets - how long
|
||||
* repeatable read may be held - limit by the number of permission evaluations
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
@@ -38,71 +38,97 @@ public class SearchParameters extends SearchStatement
|
||||
* The default limit if someone asks for a limited result set but does not say how to limit....
|
||||
*/
|
||||
private static int DEFAULT_LIMIT = 500;
|
||||
|
||||
|
||||
/*
|
||||
* Standard sort definitions for sorting in document and score order.
|
||||
*/
|
||||
public static final SortDefinition SORT_IN_DOCUMENT_ORDER_ASCENDING = new SortDefinition(SortDefinition.SortType.DOCUMENT, null, true);
|
||||
public static final SortDefinition SORT_IN_DOCUMENT_ORDER_DESCENDING = new SortDefinition(SortDefinition.SortType.DOCUMENT, null, false);
|
||||
public static final SortDefinition SORT_IN_SCORE_ORDER_ASCENDING = new SortDefinition(SortDefinition.SortType.SCORE, null, false);
|
||||
public static final SortDefinition SORT_IN_SCORE_ORDER_DESCENDING = new SortDefinition(SortDefinition.SortType.SCORE, null, true);
|
||||
|
||||
public static final SortDefinition SORT_IN_DOCUMENT_ORDER_ASCENDING = new SortDefinition(
|
||||
SortDefinition.SortType.DOCUMENT, null, true);
|
||||
|
||||
public static final SortDefinition SORT_IN_DOCUMENT_ORDER_DESCENDING = new SortDefinition(
|
||||
SortDefinition.SortType.DOCUMENT, null, false);
|
||||
|
||||
public static final SortDefinition SORT_IN_SCORE_ORDER_ASCENDING = new SortDefinition(
|
||||
SortDefinition.SortType.SCORE, null, false);
|
||||
|
||||
public static final SortDefinition SORT_IN_SCORE_ORDER_DESCENDING = new SortDefinition(
|
||||
SortDefinition.SortType.SCORE, null, true);
|
||||
|
||||
/**
|
||||
* An emum defining if the default action is to "and" or "or" unspecified components in the query register.
|
||||
* Not all search implementations will support this.
|
||||
* An emum defining if the default action is to "and" or "or" unspecified components in the query register. Not all
|
||||
* search implementations will support this.
|
||||
*/
|
||||
public enum Operator
|
||||
{
|
||||
OR, AND
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Expose as constants
|
||||
* Expose as constants
|
||||
*/
|
||||
public static final Operator OR = Operator.OR;
|
||||
|
||||
public static final Operator AND = Operator.AND;
|
||||
|
||||
|
||||
/*
|
||||
* The parameters that can be set
|
||||
*/
|
||||
private ArrayList<StoreRef> stores = new ArrayList<StoreRef>(1);
|
||||
|
||||
private ArrayList<Path> attributePaths = new ArrayList<Path>(1);
|
||||
|
||||
private ArrayList<QueryParameterDefinition> queryParameterDefinitions = new ArrayList<QueryParameterDefinition>(1);
|
||||
|
||||
private boolean excludeDataInTheCurrentTransaction = false;
|
||||
|
||||
private ArrayList<SortDefinition> sortDefinitions = new ArrayList<SortDefinition>(1);
|
||||
|
||||
private Operator defaultOperator = Operator.OR;
|
||||
|
||||
|
||||
private ArrayList<Locale> locales = new ArrayList<Locale>();
|
||||
|
||||
private MLAnalysisMode mlAnalaysisMode = null; // Pick up from config if null
|
||||
|
||||
private LimitBy limitBy = LimitBy.UNLIMITED;
|
||||
|
||||
private PermissionEvaluationMode permissionEvaluation = PermissionEvaluationMode.EAGER;
|
||||
|
||||
private int limit = DEFAULT_LIMIT;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public SearchParameters()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stores to be supported - currently there can be only one.
|
||||
* Searching across multiple stores is on the todo list.
|
||||
* Set the stores to be supported - currently there can be only one. Searching across multiple stores is on the todo
|
||||
* list.
|
||||
*
|
||||
* @param store
|
||||
*/
|
||||
public void addStore(StoreRef store)
|
||||
{
|
||||
if(stores.size() != 0)
|
||||
if (stores.size() != 0)
|
||||
{
|
||||
throw new IllegalStateException("At the moment, there can only be one store set for the search");
|
||||
}
|
||||
stores.add(store);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add paths for attributes in the result set.
|
||||
*
|
||||
* Generally this only makes sense for disconnected results sets.
|
||||
* These atttributes/paths state what must be present in the result set, akin
|
||||
* to the selection of columns is sql.
|
||||
* Add paths for attributes in the result set. Generally this only makes sense for disconnected results sets. These
|
||||
* atttributes/paths state what must be present in the result set, akin to the selection of columns is sql.
|
||||
*
|
||||
* @param attributePath
|
||||
*/
|
||||
public void addAttrbutePath(Path attributePath)
|
||||
public void addAttrbutePath(Path attributePath)
|
||||
{
|
||||
attributePaths.add(attributePath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add parameter definitions for the query - used to parameterise the query string
|
||||
*
|
||||
@@ -112,17 +138,13 @@ public class SearchParameters extends SearchStatement
|
||||
{
|
||||
queryParameterDefinitions.add(queryParameterDefinition);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If true, any data in the current transaction will be ignored in the search.
|
||||
* You will not see anything you have added in the current transaction.
|
||||
*
|
||||
* By default you will see data in the current transaction.
|
||||
* This effectively gives read committed isolation.
|
||||
*
|
||||
* There is a performance overhead for this, at least when using lucene.
|
||||
* This flag may be set to avoid that performance hit if you know you do not want to find results
|
||||
* that are yet to be committed (this includes creations, deletions and updates)
|
||||
* If true, any data in the current transaction will be ignored in the search. You will not see anything you have
|
||||
* added in the current transaction. By default you will see data in the current transaction. This effectively gives
|
||||
* read committed isolation. There is a performance overhead for this, at least when using lucene. This flag may be
|
||||
* set to avoid that performance hit if you know you do not want to find results that are yet to be committed (this
|
||||
* includes creations, deletions and updates)
|
||||
*
|
||||
* @param excludeDataInTheCurrentTransaction
|
||||
*/
|
||||
@@ -130,73 +152,32 @@ public class SearchParameters extends SearchStatement
|
||||
{
|
||||
this.excludeDataInTheCurrentTransaction = excludeDataInTheCurrentTransaction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a sort to the query (for those query languages that do not support it directly)
|
||||
* Add a sort to the query (for those query languages that do not support it directly) The first sort added is
|
||||
* treated as primary, the second as secondary etc. A helper method to create SortDefinitions.
|
||||
*
|
||||
* The first sort added is treated as primary, the second as secondary etc.
|
||||
*
|
||||
* A helper method to create SortDefinitions.
|
||||
*
|
||||
* @param field - this is intially a direct attribute on a node not an attribute on the parent etc
|
||||
* TODO: It could be a relative path at some time.
|
||||
*
|
||||
* @param ascending - true to sort ascending, false for descending.
|
||||
* @param field -
|
||||
* this is intially a direct attribute on a node not an attribute on the parent etc TODO: It could be a
|
||||
* relative path at some time.
|
||||
* @param ascending -
|
||||
* true to sort ascending, false for descending.
|
||||
*/
|
||||
public void addSort(String field, boolean ascending)
|
||||
{
|
||||
addSort(new SortDefinition(SortDefinition.SortType.FIELD, field, ascending));
|
||||
addSort(new SortDefinition(SortDefinition.SortType.FIELD, field, ascending));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a sort definition.
|
||||
*
|
||||
* @param sortDefinition - the sort definition to add. Use the static member variables
|
||||
* for sorting in score and index order.
|
||||
* @param sortDefinition -
|
||||
* the sort definition to add. Use the static member variables for sorting in score and index order.
|
||||
*/
|
||||
public void addSort(SortDefinition sortDefinition)
|
||||
{
|
||||
sortDefinitions.add(sortDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper class for sort definition.
|
||||
* Encapsulated using the lucene sortType, field name and a flag for ascending/descending.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public static class SortDefinition
|
||||
{
|
||||
|
||||
public enum SortType {FIELD, DOCUMENT, SCORE};
|
||||
|
||||
SortType sortType;
|
||||
String field;
|
||||
boolean ascending;
|
||||
|
||||
SortDefinition(SortType sortType, String field, boolean ascending)
|
||||
{
|
||||
this.sortType = sortType;
|
||||
this.field = field;
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
public boolean isAscending()
|
||||
{
|
||||
return ascending;
|
||||
}
|
||||
|
||||
public String getField()
|
||||
{
|
||||
return field;
|
||||
}
|
||||
|
||||
public SortType getSortType()
|
||||
{
|
||||
return sortType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of attribute paths that are guarenteed to be in the result set.
|
||||
@@ -208,7 +189,7 @@ public class SearchParameters extends SearchStatement
|
||||
return attributePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Is data in the current transaction excluded from the search.
|
||||
*
|
||||
* @return
|
||||
@@ -218,7 +199,7 @@ public class SearchParameters extends SearchStatement
|
||||
return excludeDataInTheCurrentTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the query parameters that apply to this query.
|
||||
*
|
||||
* @return
|
||||
@@ -247,7 +228,7 @@ public class SearchParameters extends SearchStatement
|
||||
{
|
||||
return stores;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the default operator for query elements when they are not explicit in the query.
|
||||
*
|
||||
@@ -257,7 +238,7 @@ public class SearchParameters extends SearchStatement
|
||||
{
|
||||
this.defaultOperator = defaultOperator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the default operator for query elements when they are not explicit in the query.
|
||||
*
|
||||
@@ -267,14 +248,8 @@ public class SearchParameters extends SearchStatement
|
||||
{
|
||||
return defaultOperator;
|
||||
}
|
||||
|
||||
private LimitBy limitBy = LimitBy.UNLIMITED;
|
||||
|
||||
private PermissionEvaluationMode permissionEvaluation = PermissionEvaluationMode.EAGER;
|
||||
|
||||
private int limit = DEFAULT_LIMIT;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get how the result set should be limited
|
||||
*
|
||||
* @return
|
||||
@@ -314,15 +289,110 @@ public class SearchParameters extends SearchStatement
|
||||
this.permissionEvaluation = permissionEvaluation;
|
||||
}
|
||||
|
||||
/**
|
||||
* If limiting the result set in some way, get the limiting value used.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getLimit()
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* If limiting the result set in some way, set the limiting value used.
|
||||
*
|
||||
* @param limit
|
||||
*/
|
||||
public void setLimit(int limit)
|
||||
{
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The way in which multilingual fields are treated durig a search.
|
||||
* By default, only the specified locale is used and it must be an exact match.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public MLAnalysisMode getMlAnalaysisMode()
|
||||
{
|
||||
return mlAnalaysisMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the way in which multilingual fields are treated durig a search.
|
||||
* This controls in which locales an multilingual fields will match.
|
||||
*
|
||||
* @param mlAnalaysisMode
|
||||
*/
|
||||
public void setMlAnalaysisMode(MLAnalysisMode mlAnalaysisMode)
|
||||
{
|
||||
this.mlAnalaysisMode = mlAnalaysisMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a locale to include for multi-lingual text searches.
|
||||
* If non are set, the default is to use the user's locale.
|
||||
*
|
||||
* @param locale
|
||||
*/
|
||||
public void addLocale(Locale locale)
|
||||
{
|
||||
locales.add(locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the locales used for multi-lingual text searches.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Locale> getLocales()
|
||||
{
|
||||
return Collections.unmodifiableList(locales);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper class for sort definition. Encapsulated using the lucene sortType, field name and a flag for
|
||||
* ascending/descending.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public static class SortDefinition
|
||||
{
|
||||
|
||||
public enum SortType
|
||||
{
|
||||
FIELD, DOCUMENT, SCORE
|
||||
};
|
||||
|
||||
SortType sortType;
|
||||
|
||||
String field;
|
||||
|
||||
boolean ascending;
|
||||
|
||||
SortDefinition(SortType sortType, String field, boolean ascending)
|
||||
{
|
||||
this.sortType = sortType;
|
||||
this.field = field;
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
public boolean isAscending()
|
||||
{
|
||||
return ascending;
|
||||
}
|
||||
|
||||
public String getField()
|
||||
{
|
||||
return field;
|
||||
}
|
||||
|
||||
public SortType getSortType()
|
||||
{
|
||||
return sortType;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user