mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V1.4 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3925 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3965 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3966 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -42,6 +42,11 @@ public class ClosingIndexSearcher extends IndexSearcher
|
||||
this.reader = r;
|
||||
}
|
||||
|
||||
/*package*/ IndexReader getReader()
|
||||
{
|
||||
return reader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
|
@@ -145,7 +145,7 @@ public abstract class LuceneBase2
|
||||
}
|
||||
}
|
||||
|
||||
protected Searcher getSearcher(LuceneIndexer2 luceneIndexer) throws LuceneIndexException
|
||||
protected ClosingIndexSearcher getSearcher(LuceneIndexer2 luceneIndexer) throws LuceneIndexException
|
||||
{
|
||||
// If we know the delta id we should do better
|
||||
|
||||
|
@@ -43,7 +43,6 @@ import org.alfresco.repo.search.IndexerException;
|
||||
import org.alfresco.repo.search.impl.lucene.fts.FTSIndexerAware;
|
||||
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
|
||||
import org.alfresco.repo.search.impl.lucene.index.TransactionStatus;
|
||||
import org.alfresco.repo.search.impl.lucene.index.IndexInfo.LockWork;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -1316,7 +1315,7 @@ public class LuceneIndexerImpl2 extends LuceneBase2 implements LuceneIndexer2
|
||||
|
||||
if (includeDirectoryDocuments)
|
||||
{
|
||||
if (nodeTypeDef.getChildAssociations().size() > 0)
|
||||
if (nodeTypeDef != null && nodeTypeDef.getChildAssociations().size() > 0)
|
||||
{
|
||||
if (directPaths.contains(pair.getFirst()))
|
||||
{
|
||||
|
@@ -59,17 +59,13 @@ import org.saxpath.SAXPathException;
|
||||
import com.werken.saxpath.XPathReader;
|
||||
|
||||
/**
|
||||
* The Lucene implementation of Searcher At the moment we support only lucene
|
||||
* based queries.
|
||||
*
|
||||
* TODO: Support for other query languages
|
||||
* The Lucene implementation of Searcher At the moment we support only lucene based queries. TODO: Support for other query languages
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Default field name
|
||||
*/
|
||||
@@ -90,9 +86,7 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get an initialised searcher for the store and transaction Normally we do
|
||||
* not search against a a store and delta. Currently only gets the searcher
|
||||
* against the main index.
|
||||
* Get an initialised searcher for the store and transaction Normally we do not search against a a store and delta. Currently only gets the searcher against the main index.
|
||||
*
|
||||
* @param storeRef
|
||||
* @param deltaId
|
||||
@@ -115,9 +109,7 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an intialised searcher for the store. No transactional ammendsmends
|
||||
* are searched.
|
||||
*
|
||||
* Get an intialised searcher for the store. No transactional ammendsmends are searched.
|
||||
*
|
||||
* @param storeRef
|
||||
* @return
|
||||
@@ -134,7 +126,7 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
|
||||
public boolean indexExists()
|
||||
{
|
||||
//return mainIndexExists();
|
||||
// return mainIndexExists();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -220,7 +212,7 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
|
||||
Query query = LuceneQueryParser.parse(parameterisedQueryString, DEFAULT_FIELD, new LuceneAnalyser(
|
||||
dictionaryService), namespacePrefixResolver, dictionaryService, defaultOperator);
|
||||
Searcher searcher = getSearcher(indexer);
|
||||
ClosingIndexSearcher searcher = getSearcher(indexer);
|
||||
if (searcher == null)
|
||||
{
|
||||
// no index return an empty result set
|
||||
@@ -238,7 +230,14 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
switch (sd.getSortType())
|
||||
{
|
||||
case FIELD:
|
||||
fields[index++] = new SortField(sd.getField(), !sd.isAscending());
|
||||
if (searcher.getReader().getFieldNames().contains(sd.getField()))
|
||||
{
|
||||
fields[index++] = new SortField(sd.getField(), !sd.isAscending());
|
||||
}
|
||||
else
|
||||
{
|
||||
fields[index++] = new SortField(null, SortField.DOC, !sd.isAscending());
|
||||
}
|
||||
break;
|
||||
case DOCUMENT:
|
||||
fields[index++] = new SortField(null, SortField.DOC, !sd.isAscending());
|
||||
@@ -348,8 +347,7 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
}
|
||||
|
||||
/**
|
||||
* The definitions must provide a default value, or of not there must be a
|
||||
* parameter to provide the value
|
||||
* The definitions must provide a default value, or of not there must be a parameter to provide the value
|
||||
*
|
||||
* @param definition
|
||||
* @param queryParameters
|
||||
@@ -396,12 +394,9 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
}
|
||||
|
||||
/*
|
||||
* Parameterise the query string - not sure if it is required to escape
|
||||
* lucence spacials chars The parameters could be used to build the query -
|
||||
* the contents of parameters should alread have been escaped if required.
|
||||
* ... mush better to provide the parameters and work out what to do TODO:
|
||||
* conditional query escapement - may be we should have a parameter type
|
||||
* that is not escaped
|
||||
* Parameterise the query string - not sure if it is required to escape lucence spacials chars The parameters could be used to build the query - the contents of parameters
|
||||
* should alread have been escaped if required. ... mush better to provide the parameters and work out what to do TODO: conditional query escapement - may be we should have a
|
||||
* parameter type that is not escaped
|
||||
*/
|
||||
private String parameterise(String unparameterised, Map<QName, QueryParameterDefinition> map,
|
||||
QueryParameter[] queryParameters, NamespacePrefixResolver nspr) throws QueryParameterisationException
|
||||
@@ -567,7 +562,6 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
|
||||
/**
|
||||
* @return Returns true if the pattern is present, otherwise false.
|
||||
*
|
||||
* @see #setIndexer(Indexer)
|
||||
* @see #setSearcher(SearchService)
|
||||
*/
|
||||
|
@@ -381,6 +381,10 @@ public class LuceneTest2 extends TestCase
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public void firstTest() throws Exception
|
||||
{
|
||||
testSort();
|
||||
}
|
||||
|
||||
public void test0() throws Exception
|
||||
{
|
||||
@@ -1063,6 +1067,17 @@ public class LuceneTest2 extends TestCase
|
||||
results.close();
|
||||
|
||||
luceneFTS.resume();
|
||||
|
||||
|
||||
SearchParameters sp17 = new SearchParameters();
|
||||
sp17.addStore(rootNodeRef.getStoreRef());
|
||||
sp17.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
sp17.setQuery("PATH:\"//.\"");
|
||||
sp17.addSort("cabbage", false);
|
||||
results = searcher.query(sp17);
|
||||
results.close();
|
||||
|
||||
luceneFTS.resume();
|
||||
}
|
||||
|
||||
public void test1() throws Exception
|
||||
|
Reference in New Issue
Block a user