|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.processor.BaseProcessorExtension
org.alfresco.repo.jscript.BaseScopableProcessorExtension
org.alfresco.repo.jscript.Search
public class Search
Search component for use by the ScriptService.
Provides access to Lucene search facilities including saved search objects. The results from a search are returned as an array (collection) of scriptable Node wrapper objects.
The object is added to the root of the model to provide syntax such as:
var results = search.luceneSearch(statement);
and
var results = search.savedSearch(node);
Nested Class Summary | |
---|---|
class |
Search.SortColumn
Search sort column |
Field Summary | |
---|---|
protected Repository |
repository
Repository helper |
protected ServiceRegistry |
services
Service registry |
protected org.alfresco.service.cmr.repository.StoreRef |
storeRef
Default store reference |
Constructor Summary | |
---|---|
Search()
|
Method Summary | |
---|---|
ScriptNode |
findNode(org.alfresco.service.cmr.repository.NodeRef ref)
Find a single Node by the Node reference |
ScriptNode |
findNode(java.lang.String ref)
Find a single Node by the Node reference |
ScriptNode |
findNode(java.lang.String referenceType,
java.lang.String[] reference)
Helper to convert a Web Script Request URL to a Node Ref 1) Node - {store_type}/{store_id}/{node_id} Resolve to node via its Node Reference. |
java.lang.String |
ISO9075Decode(java.lang.String s)
Decode a string from ISO9075 |
java.lang.String |
ISO9075Encode(java.lang.String s)
Encode a string to ISO9075 - used to build valid paths for Lucene queries etc. |
boolean |
isValidXpathQuery(java.lang.String query)
Validation Xpath query |
org.mozilla.javascript.Scriptable |
luceneSearch(java.lang.String search)
Execute a Lucene search |
org.mozilla.javascript.Scriptable |
luceneSearch(java.lang.String store,
java.lang.String search)
Execute a Lucene search |
org.mozilla.javascript.Scriptable |
luceneSearch(java.lang.String search,
java.lang.String sortColumn,
boolean asc)
Execute a Lucene search (sorted) |
org.mozilla.javascript.Scriptable |
luceneSearch(java.lang.String search,
java.lang.String sortColumn,
boolean asc,
int max)
|
org.mozilla.javascript.Scriptable |
luceneSearch(java.lang.String store,
java.lang.String search,
java.lang.String sortColumn,
boolean asc)
|
org.mozilla.javascript.Scriptable |
luceneSearch(java.lang.String store,
java.lang.String search,
java.lang.String sortColumn,
boolean asc,
int max)
Execute a Lucene search (sorted) |
org.mozilla.javascript.Scriptable |
query(java.lang.Object search)
Execute a query based on the supplied search definition object. |
protected java.lang.Object[] |
query(org.alfresco.service.cmr.search.SearchParameters sp,
boolean exceptionOnError)
Execute the query Removes any duplicates that may be present (ID search can cause duplicates - it is better to remove them here) |
protected java.lang.Object[] |
query(java.lang.String store,
java.lang.String search,
Search.SortColumn[] sort,
java.lang.String language)
Execute the query Removes any duplicates that may be present (ID search can cause duplicates - it is better to remove them here) |
protected java.lang.Object[] |
query(java.lang.String store,
java.lang.String search,
Search.SortColumn[] sort,
java.lang.String language,
int maxResults,
int skipResults)
Execute the query Removes any duplicates that may be present (ID search can cause duplicates - it is better to remove them here) |
org.mozilla.javascript.Scriptable |
savedSearch(ScriptNode savedSearch)
Execute a saved Lucene search |
org.mozilla.javascript.Scriptable |
savedSearch(java.lang.String searchRef)
Execute a saved Lucene search |
org.mozilla.javascript.Scriptable |
selectNodes(java.lang.String search)
Execute a SelectNodes XPath search |
org.mozilla.javascript.Scriptable |
selectNodes(java.lang.String store,
java.lang.String search)
Execute a SelectNodes XPath search |
void |
setRepositoryHelper(Repository repository)
Set the repository helper |
void |
setServiceRegistry(ServiceRegistry services)
Set the service registry |
void |
setStoreUrl(java.lang.String storeRef)
Set the default store reference |
ScriptNode[] |
tagSearch(java.lang.String store,
java.lang.String tag)
Searchs the store for all nodes with the given tag applied. |
org.mozilla.javascript.Scriptable |
xpathSearch(java.lang.String search)
Execute a XPath search |
org.mozilla.javascript.Scriptable |
xpathSearch(java.lang.String store,
java.lang.String search)
Execute a XPath search |
Methods inherited from class org.alfresco.repo.jscript.BaseScopableProcessorExtension |
---|
getScope, setScope |
Methods inherited from class org.alfresco.repo.processor.BaseProcessorExtension |
---|
getExtensionName, register, setExtensionName, setProcessor |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ServiceRegistry services
protected org.alfresco.service.cmr.repository.StoreRef storeRef
protected Repository repository
Constructor Detail |
---|
public Search()
Method Detail |
---|
public void setStoreUrl(java.lang.String storeRef)
storeRef
- the default store referencepublic void setServiceRegistry(ServiceRegistry services)
services
- the service registrypublic void setRepositoryHelper(Repository repository)
repository
- the repository helperpublic ScriptNode findNode(org.alfresco.service.cmr.repository.NodeRef ref)
ref
- The NodeRef of the Node to find
public ScriptNode findNode(java.lang.String ref)
ref
- The fully qualified NodeRef in String format
public ScriptNode findNode(java.lang.String referenceType, java.lang.String[] reference)
referenceType
- one of node, path, avmpath or qnamereference
- array of reference segments (as described above for each reference type)
public org.mozilla.javascript.Scriptable xpathSearch(java.lang.String search)
search
- XPath search string to execute
public org.mozilla.javascript.Scriptable xpathSearch(java.lang.String store, java.lang.String search)
store
- Store reference to search against i.e. workspace://SpacesStoresearch
- XPath search string to execute
public org.mozilla.javascript.Scriptable selectNodes(java.lang.String search)
search
- SelectNodes XPath search string to execute
public org.mozilla.javascript.Scriptable selectNodes(java.lang.String store, java.lang.String search)
store
- Store reference to search against i.e. workspace://SpacesStoresearch
- SelectNodes XPath search string to execute
public boolean isValidXpathQuery(java.lang.String query)
query
- xpath query
public org.mozilla.javascript.Scriptable luceneSearch(java.lang.String search)
search
- Lucene search string to execute
public org.mozilla.javascript.Scriptable luceneSearch(java.lang.String store, java.lang.String search)
store
- Store reference to search against i.e. workspace://SpacesStoresearch
- Lucene search string to execute
public org.mozilla.javascript.Scriptable luceneSearch(java.lang.String search, java.lang.String sortColumn, boolean asc)
search
- Lucene search string to executesortKey
- property name to sort onasc
- true => ascending sort
public org.mozilla.javascript.Scriptable luceneSearch(java.lang.String search, java.lang.String sortColumn, boolean asc, int max)
public org.mozilla.javascript.Scriptable luceneSearch(java.lang.String store, java.lang.String search, java.lang.String sortColumn, boolean asc)
public org.mozilla.javascript.Scriptable luceneSearch(java.lang.String store, java.lang.String search, java.lang.String sortColumn, boolean asc, int max)
store
- Store reference to search against i.e. workspace://SpacesStoresearch
- Lucene search string to executesortKey
- property name to sort onasc
- true => ascending sort
public org.mozilla.javascript.Scriptable savedSearch(ScriptNode savedSearch)
savedSearch
- Node that contains the saved search XML content
public org.mozilla.javascript.Scriptable savedSearch(java.lang.String searchRef)
searchRef
- NodeRef string that points to the node containing saved search XML content
public ScriptNode[] tagSearch(java.lang.String store, java.lang.String tag)
store
- store ref string, default used if null providedtag
- tag name
public org.mozilla.javascript.Scriptable query(java.lang.Object search)
search
{
query: string, mandatory, in appropriate format and encoded for the given language
store: string, optional, defaults to 'workspace://SpacesStore'
language: string, optional, one of: lucene, xpath, jcr-xpath, fts-alfresco - defaults to 'lucene'
templates: [], optional, Array of query language template objects (see below) - if supported by the language
sort: [], optional, Array of sort column objects (see below) - if supported by the language
page: object, optional, paging information object (see below) - if supported by the language
namespace: string, optional, the default namespace for properties
defaultField: string, optional, the default field for query elements when not explicit in the query
onerror: string optional, result on error - one of: exception, no-results - defaults to 'exception'
}
sort
{
column: string, mandatory, sort column in appropriate format for the language
ascending: boolean optional, defaults to false
}
page
{
maxItems: int, optional, max number of items to return in result set
skipCount: int optional, number of items to skip over before returning results
}
template
{
field: string, mandatory, custom field name for the template
template: string mandatory, query template replacement for the template
}
Note that only some query languages support custom query templates, such as 'fts-alfresco'.
See the following documentation for more details:
http://wiki.alfresco.com/wiki/Full_Text_Search_Query_Syntax#Templates
search
- Search definition object as above
public java.lang.String ISO9075Encode(java.lang.String s)
s
- Value to encode
public java.lang.String ISO9075Decode(java.lang.String s)
s
- Value to decode
protected java.lang.Object[] query(java.lang.String store, java.lang.String search, Search.SortColumn[] sort, java.lang.String language)
store
- StoreRef to search against - null for default configured storesearch
- Lucene search to executesort
- Columns to sort bylanguage
- Search language to use e.g. SearchService.LANGUAGE_LUCENE
protected java.lang.Object[] query(java.lang.String store, java.lang.String search, Search.SortColumn[] sort, java.lang.String language, int maxResults, int skipResults)
store
- StoreRef to search against - null for default configured storesearch
- Lucene search to executesort
- Columns to sort bylanguage
- Search language to use e.g. SearchService.LANGUAGE_LUCENEmaxResults
- Maximum results to return if > 0skipResults
- Results to skip in the result set
protected java.lang.Object[] query(org.alfresco.service.cmr.search.SearchParameters sp, boolean exceptionOnError)
sp
- SearchParameters describing the search to execute.exceptionOnError
- True to throw a runtime exception on error, false to return empty resultset
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |