mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV/SWIFT to HEAD
26373: WIP: ALF-7339: RSOLR 009: Index track and build from SOLR - track content, track dates, basic sorting 26388: WIP: ALF-7339: RSOLR 009: Index track and build from SOLR - basic tracking of d:text and d:mltext (not dual tokenisation and identifier support) 26527: WIP ALF-7339: RSOLR 009: Index track and build from SOLR - track d:content, d:mltext, d:text - start of cross locale search and ordering support int the index (not at query time yet) - no dual tokenisation support yet - currently adding all fields for tokenized BOTH - .sort needs additional tokenisation support to use a different separator (\u0000 used to indicate locale and split stuff - better toe use {en}woof style with \u0000 split 26822: ALF-8166: RINF 10: treenode.get.js - tweak to use "childFileFolders" 26825: ALF-8133: RINF 10: ScriptNode - update "childByNamePath" to use optimised NodeService.getChildByName 26850: ALF-8133: RINF 10: ScriptNode - update "childByNamePath" to use optimised NodeService.getChildByName - follow-on to r26825 26862: ALF-8110: RINF 10: doclist.get.js - update "path" filter to use DB-based queries (by default) - milestone check-in for review and comparison (note: sorting will be pushed down as part of paging support in lower layers) 26872: Updated SOLR dev env 26915: ALF-8224: part 1: encapsulate cmis dictionary for SOLR usage 27017: Javadoc: removed uncommented param 27018: Added 'namePattern' property to NamedObjectRegistry to enforce naming conventions where required 27019: CannedQuery interface and related infrastructure - Provides basic support for query, sort, filter and page - CannedQueryFactory allows more complex implementations where required - Should be enough of a starter for tasks requiring miscellaneous queries - ALF-7167: Canned queries 27037: WCM QS Needs the Web-Client, so define the dependency to Eclipse 27041: Move WCM-QS test setup to a common base class 27044: Start to conver the WCM QS behaviour from JS to Java 27080: Added comment section for NodeLocator script declarations 27081: General cleanup: Removed non-javadocs, empty javadocs, unused code, etc 27104: Fixed ALF-7476: Typo in output from MMT 27114: ALF-7479: RSOLR 016: Query Handler ALF-7480: RSOLR 017: SOLR result set ALF-7481: RSOLR 018: Execute query against SOLR - First working stack git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28286 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -44,6 +44,7 @@ import org.alfresco.repo.search.MLAnalysisMode;
|
||||
import org.alfresco.repo.search.QueryRegisterComponent;
|
||||
import org.alfresco.repo.search.SearcherException;
|
||||
import org.alfresco.repo.search.impl.NodeSearcher;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
|
||||
import org.alfresco.repo.search.impl.parsers.AlfrescoFunctionEvaluationContext;
|
||||
import org.alfresco.repo.search.impl.parsers.FTSQueryParser;
|
||||
|
@@ -23,6 +23,7 @@ import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.search.IndexerException;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.index.IndexInfo;
|
||||
import org.alfresco.repo.search.impl.lucene.index.TransactionStatus;
|
||||
import org.alfresco.repo.search.impl.lucene.index.IndexInfo.LockWork;
|
||||
|
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
class MultiReader extends Reader
|
||||
{
|
||||
Reader first;
|
||||
|
||||
Reader second;
|
||||
|
||||
boolean firstActive = true;
|
||||
|
||||
MultiReader(Reader first, Reader second)
|
||||
{
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
IOException ioe = null;
|
||||
try
|
||||
{
|
||||
first.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ioe = e;
|
||||
}
|
||||
|
||||
second.close();
|
||||
if (ioe != null)
|
||||
{
|
||||
throw ioe;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(char[] cbuf, int off, int len) throws IOException
|
||||
{
|
||||
synchronized (lock)
|
||||
{
|
||||
if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0))
|
||||
{
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
else if (len == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
int c;
|
||||
if(firstActive)
|
||||
{
|
||||
c = first.read();
|
||||
if(c == -1)
|
||||
{
|
||||
firstActive = false;
|
||||
c = second.read();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c = second.read();
|
||||
}
|
||||
if(c == -1)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cbuf[off+i] = (char)c;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
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.search.SearchParameters.SortDefinition;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.apache.commons.codec.net.URLCodec;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
||||
import org.apache.commons.httpclient.auth.AuthScope;
|
||||
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.commons.httpclient.params.HttpClientParams;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
|
||||
/**
|
||||
* @author Andy
|
||||
*/
|
||||
public class SolrAlfrescoFTSQueryLanguage implements LuceneQueryLanguageSPI
|
||||
{
|
||||
static Log s_logger = LogFactory.getLog(SolrAlfrescoFTSQueryLanguage.class);
|
||||
|
||||
private NodeDAO nodeDAO;
|
||||
|
||||
private PermissionService permissionService;
|
||||
|
||||
/**
|
||||
* @param nodeDAO the nodeDAO to set
|
||||
*/
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissionService the permissionService to set
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @seeorg.alfresco.repo.search.impl.lucene.LuceneQueryLanguageSPI#executeQuery(org.alfresco.service.cmr.search.
|
||||
* SearchParameters, org.alfresco.repo.search.impl.lucene.ADMLuceneSearcherImpl)
|
||||
*/
|
||||
@Override
|
||||
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.getParams().setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
|
||||
httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin"));
|
||||
|
||||
StringBuilder url = new StringBuilder("http://localhost:8080/solr/test/alfresco/afts");
|
||||
//url.append("?q=");
|
||||
//URLCodec encoder = new URLCodec();
|
||||
//url.append(encoder.encode(searchParameters.getQuery(), "UTF-8"));
|
||||
url.append("?wt=json");
|
||||
url.append("&fl=*,score");
|
||||
if(searchParameters.getMaxItems() > 0)
|
||||
{
|
||||
url.append("&rows=").append(searchParameters.getMaxItems());
|
||||
}
|
||||
url.append("&df=").append(searchParameters.getDefaultFieldName());
|
||||
url.append("&start=").append(searchParameters.getSkipCount());
|
||||
|
||||
// Authorities go over as filter queries
|
||||
|
||||
StringBuilder authQuery = new StringBuilder();
|
||||
for(String authority : permissionService.getAuthorisations())
|
||||
{
|
||||
if(authQuery.length() > 0)
|
||||
{
|
||||
authQuery.append(" ");
|
||||
}
|
||||
authQuery.append("AUTHORITY:\"").append(authority).append("\"");
|
||||
}
|
||||
|
||||
url.append("&fq=");
|
||||
URLCodec encoder = new URLCodec();
|
||||
url.append(encoder.encode(authQuery.toString(), "UTF-8"));
|
||||
|
||||
// facets would go on url?
|
||||
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("query", searchParameters.getQuery());
|
||||
//body.put("defaultField", searchParameters.getDefaultFieldName());
|
||||
JSONArray locales = new JSONArray();
|
||||
for(Locale locale : searchParameters.getLocales())
|
||||
{
|
||||
locales.put(DefaultTypeConverter.INSTANCE.convert(String.class, locale));
|
||||
}
|
||||
body.put("locales", locales);
|
||||
|
||||
JSONArray orderings = new JSONArray();
|
||||
for(SortDefinition sortDefinition : searchParameters.getSortDefinitions())
|
||||
{
|
||||
JSONObject ordering = new JSONObject();
|
||||
ordering.put("field", sortDefinition.getField());
|
||||
ordering.put("isAscending", sortDefinition.isAscending());
|
||||
orderings.put(ordering);
|
||||
}
|
||||
body.put("sort", orderings);
|
||||
|
||||
JSONArray templates = new JSONArray();
|
||||
for(String templateName : searchParameters.getQueryTemplates().keySet())
|
||||
{
|
||||
JSONObject template = new JSONObject();
|
||||
template.put("name", templateName);
|
||||
template.put("template", searchParameters.getQueryTemplates().get(templateName));
|
||||
templates.put(template);
|
||||
}
|
||||
body.put("templates", templates);
|
||||
|
||||
JSONArray allAttributes = new JSONArray();
|
||||
for(String attribute : searchParameters.getAllAttributes())
|
||||
{
|
||||
allAttributes.put(attribute);
|
||||
}
|
||||
body.put("allAttributes", allAttributes);
|
||||
|
||||
body.put("defaultFTSOperator", searchParameters.getDefaultFTSOperator());
|
||||
body.put("defaultFTSFieldOperator", searchParameters.getDefaultFTSFieldOperator());
|
||||
if(searchParameters.getMlAnalaysisMode() != null)
|
||||
{
|
||||
body.put("mlAnalaysisMode", searchParameters.getMlAnalaysisMode().toString());
|
||||
}
|
||||
body.put("defaultNamespace", searchParameters.getNamespace());
|
||||
|
||||
|
||||
JSONArray textAttributes = new JSONArray();
|
||||
for(String attribute : searchParameters.getTextAttributes())
|
||||
{
|
||||
textAttributes.put(attribute);
|
||||
}
|
||||
body.put("textAttributes", textAttributes);
|
||||
|
||||
PostMethod post = new PostMethod(url.toString());
|
||||
post.setRequestEntity(new ByteArrayRequestEntity(body.toString().getBytes("UTF-8"), "application/json"));
|
||||
|
||||
httpClient.executeMethod(post);
|
||||
|
||||
if (post.getStatusCode() != HttpServletResponse.SC_OK)
|
||||
{
|
||||
throw new LuceneQueryParserException("Request failed " + post.getStatusCode()+" "+url.toString());
|
||||
}
|
||||
|
||||
|
||||
Reader reader = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream()));
|
||||
// TODO - replace with streaming-based solution e.g. SimpleJSON ContentHandler
|
||||
JSONObject json = new JSONObject(new JSONTokener(reader));
|
||||
SolrJSONResultSet results = new SolrJSONResultSet(json, nodeDAO, searchParameters);
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Sent :"+url);
|
||||
s_logger.debug(" with: "+body.toString());
|
||||
s_logger.debug("Got: "+results.getNumberFound()+ " in "+results.getQueryTime()+ " ms");
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
throw new LuceneQueryParserException("", e);
|
||||
}
|
||||
catch (HttpException e)
|
||||
{
|
||||
throw new LuceneQueryParserException("", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new LuceneQueryParserException("", e);
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
throw new LuceneQueryParserException("", e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return SearchService.LANGUAGE_SOLR_FTS_ALFRESCO;
|
||||
}
|
||||
|
||||
public void setFactories(List<AbstractLuceneIndexerAndSearcherFactory> factories)
|
||||
{
|
||||
for (AbstractLuceneIndexerAndSearcherFactory factory : factories)
|
||||
{
|
||||
factory.registerQueryLanguage(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SolrAlfrescoFTSQueryLanguage solrAlfrescoFTSQueryLanguage = new SolrAlfrescoFTSQueryLanguage();
|
||||
SearchParameters sp = new SearchParameters();
|
||||
sp.setQuery("PATH:\"//.\"");
|
||||
sp.setMaxItems(100);
|
||||
sp.setSkipCount(12);
|
||||
ResultSet rs = solrAlfrescoFTSQueryLanguage.executeQuery(sp, null);
|
||||
System.out.println("Found "+rs.length());
|
||||
System.out.println("More "+rs.hasMore());
|
||||
System.out.println("Start "+rs.getStart());
|
||||
|
||||
for(ResultSetRow row : rs)
|
||||
{
|
||||
System.out.println("Score "+row.getScore());
|
||||
}
|
||||
rs.close();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.search.SimpleResultSetMetaData;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.search.LimitBy;
|
||||
import org.alfresco.service.cmr.search.PermissionEvaluationMode;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.ResultSetMetaData;
|
||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author Andy
|
||||
*/
|
||||
public class SolrJSONResultSet implements ResultSet
|
||||
{
|
||||
private NodeDAO nodeDAO;
|
||||
|
||||
private ArrayList<Pair<Long, Float>> page;
|
||||
|
||||
private ResultSetMetaData rsmd;
|
||||
|
||||
private Long status;
|
||||
|
||||
private Long queryTime;
|
||||
|
||||
private Long numberFound;
|
||||
|
||||
private Long start;
|
||||
|
||||
private Float maxScore;
|
||||
|
||||
private SimpleResultSetMetaData resultSetMetaData;
|
||||
|
||||
/**
|
||||
* Detached result set based on that provided
|
||||
* @param resultSet
|
||||
*/
|
||||
public SolrJSONResultSet(JSONObject json, NodeDAO nodeDAO, SearchParameters searchParameters)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
this.resultSetMetaData = new SimpleResultSetMetaData(LimitBy.UNLIMITED, PermissionEvaluationMode.EAGER, searchParameters);
|
||||
try
|
||||
{
|
||||
JSONObject responseHeader = json.getJSONObject("responseHeader");
|
||||
status = responseHeader.getLong("status");
|
||||
queryTime = responseHeader.getLong("QTime");
|
||||
|
||||
JSONObject response = json.getJSONObject("response");
|
||||
numberFound = response.getLong("numFound");
|
||||
start = response.getLong("start");
|
||||
maxScore = Float.valueOf(response.getString("maxScore"));
|
||||
|
||||
JSONArray docs = response.getJSONArray("docs");
|
||||
|
||||
int numDocs = docs.length();
|
||||
page = new ArrayList<Pair<Long, Float>>(numDocs);
|
||||
for(int i = 0; i < numDocs; i++)
|
||||
{
|
||||
JSONObject doc = docs.getJSONObject(i);
|
||||
Long dbid = doc.getLong("DBID");
|
||||
Float score = Float.valueOf(doc.getString("score"));
|
||||
page.add(new Pair<Long, Float>(dbid, score));
|
||||
|
||||
for(Iterator it = doc.keys(); it.hasNext(); /* */)
|
||||
{
|
||||
String key = (String)it.next();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#close()
|
||||
*/
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
// NO OP
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getBulkFetch()
|
||||
*/
|
||||
@Override
|
||||
public boolean getBulkFetch()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getBulkFetchSize()
|
||||
*/
|
||||
@Override
|
||||
public int getBulkFetchSize()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getChildAssocRef(int)
|
||||
*/
|
||||
@Override
|
||||
public ChildAssociationRef getChildAssocRef(int n)
|
||||
{
|
||||
Pair<Long, ChildAssociationRef> primaryParentAssoc = nodeDAO.getPrimaryParentAssoc(page.get(n).getFirst());
|
||||
if(primaryParentAssoc != null)
|
||||
{
|
||||
return nodeDAO.getPrimaryParentAssoc(page.get(n).getFirst()).getSecond();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getChildAssocRefs()
|
||||
*/
|
||||
@Override
|
||||
public List<ChildAssociationRef> getChildAssocRefs()
|
||||
{
|
||||
ArrayList<ChildAssociationRef> refs = new ArrayList<ChildAssociationRef>(page.size());
|
||||
for(int i = 0; i < page.size(); i++ )
|
||||
{
|
||||
refs.add( getChildAssocRef(i));
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getNodeRef(int)
|
||||
*/
|
||||
@Override
|
||||
public NodeRef getNodeRef(int n)
|
||||
{
|
||||
// TODO: lost nodes?
|
||||
return nodeDAO.getNodePair(page.get(n).getFirst()).getSecond();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getNodeRefs()
|
||||
*/
|
||||
@Override
|
||||
public List<NodeRef> getNodeRefs()
|
||||
{
|
||||
ArrayList<NodeRef> refs = new ArrayList<NodeRef>(page.size());
|
||||
for(int i = 0; i < page.size(); i++ )
|
||||
{
|
||||
refs.add( getNodeRef(i));
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getResultSetMetaData()
|
||||
*/
|
||||
@Override
|
||||
public ResultSetMetaData getResultSetMetaData()
|
||||
{
|
||||
return resultSetMetaData;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getRow(int)
|
||||
*/
|
||||
@Override
|
||||
public ResultSetRow getRow(int i)
|
||||
{
|
||||
return new SolrJSONResultSetRow(this, i);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getScore(int)
|
||||
*/
|
||||
@Override
|
||||
public float getScore(int n)
|
||||
{
|
||||
return page.get(n).getSecond();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#getStart()
|
||||
*/
|
||||
@Override
|
||||
public int getStart()
|
||||
{
|
||||
return start.intValue();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#hasMore()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasMore()
|
||||
{
|
||||
return numberFound.longValue() > (start.longValue() + page.size() + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#length()
|
||||
*/
|
||||
@Override
|
||||
public int length()
|
||||
{
|
||||
return page.size();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#setBulkFetch(boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean setBulkFetch(boolean bulkFetch)
|
||||
{
|
||||
return bulkFetch;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetSPI#setBulkFetchSize(int)
|
||||
*/
|
||||
@Override
|
||||
public int setBulkFetchSize(int bulkFetchSize)
|
||||
{
|
||||
return bulkFetchSize;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
*/
|
||||
@Override
|
||||
public Iterator<ResultSetRow> iterator()
|
||||
{
|
||||
return new SolrJSONResultSetRowIterator(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the queryTime
|
||||
*/
|
||||
public Long getQueryTime()
|
||||
{
|
||||
return queryTime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the numberFound
|
||||
*/
|
||||
public Long getNumberFound()
|
||||
{
|
||||
return numberFound;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.search.AbstractResultSetRow;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
|
||||
/**
|
||||
* @author Andy
|
||||
*/
|
||||
public class SolrJSONResultSetRow extends AbstractResultSetRow
|
||||
{
|
||||
|
||||
/**
|
||||
* @param resultSet
|
||||
* @param index
|
||||
*/
|
||||
public SolrJSONResultSetRow(ResultSet resultSet, int index)
|
||||
{
|
||||
super(resultSet, index);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetRow#getNodeRef(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public NodeRef getNodeRef(String selectorName)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetRow#getNodeRefs()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, NodeRef> getNodeRefs()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetRow#getScore(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public float getScore(String selectorName)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.search.ResultSetRow#getScores()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Float> getScores()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene;
|
||||
|
||||
import org.alfresco.repo.search.AbstractResultSetRowIterator;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||
|
||||
/**
|
||||
* @author Andy
|
||||
*
|
||||
*/
|
||||
public class SolrJSONResultSetRowIterator extends AbstractResultSetRowIterator
|
||||
{
|
||||
|
||||
/**
|
||||
* @param resultSet
|
||||
*/
|
||||
public SolrJSONResultSetRowIterator(ResultSet resultSet)
|
||||
{
|
||||
super(resultSet);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ResultSetRow next()
|
||||
{
|
||||
return new SolrJSONResultSetRow((SolrJSONResultSet)getResultSet(), moveToNextPosition());
|
||||
}
|
||||
|
||||
public ResultSetRow previous()
|
||||
{
|
||||
return new SolrJSONResultSetRow((SolrJSONResultSet)getResultSet(), moveToPreviousPosition());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user