VIVO-742 Many changes to remove "solr" from methods, variables, classes.

This commit is contained in:
Jim Blake 2014-04-22 17:58:58 -04:00
parent 1bb5153857
commit bf71c639fb
39 changed files with 347 additions and 277 deletions

View file

@ -41,7 +41,7 @@ display:RequiredAction a owl:Class ;
a owl:Class ;
rdfs:comment "Data getter for running a SPARQL query." .
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter>
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter>
a owl:Class ;
rdfs:comment "A data getter for a Solr Class search, i.e. get individuals for VClass" .

View file

@ -33,11 +33,12 @@ public class IndividualListRdfController extends VitroHttpServlet {
@Override
public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
// Make the query
String vclassUri = req.getParameter("vclass");
String queryStr = VitroSearchTermNames.RDFTYPE + ":\"" + vclassUri + "\"";
SearchQuery query = ApplicationUtils.instance().getSearchEngine().createQuery(queryStr);
SearchQuery query = search.createQuery(queryStr);
query.setStart(0)
.setRows(ENTITY_LIST_CONTROLLER_MAX_RESULTS)
.addFields(VitroSearchTermNames.URI);
@ -45,11 +46,10 @@ public class IndividualListRdfController extends VitroHttpServlet {
//.addSortField(VitroSearchTermNames.NAME_LOWERCASE_SINGLE_VALUED);
// Execute the query
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
SearchResponse response = null;
try {
response = solr.query(query);
response = search.query(query);
} catch (Throwable t) {
log.error(t, t);
}

View file

@ -1,14 +1,13 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.accounts.admin.ajax;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.AC_NAME_STEMMED;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_LOWERCASE_SINGLE_VALUED;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_RAW;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_UNSTEMMED;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.RDFTYPE;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.URI;
import static edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils.Conjunction.OR;
import static edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils.Conjunction.OR;
import java.io.IOException;
import java.util.Collection;
@ -43,10 +42,10 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineExcepti
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery.Order;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResponse;
import edu.cornell.mannlib.vitro.webapp.utils.solr.AutoCompleteWords;
import edu.cornell.mannlib.vitro.webapp.utils.solr.FieldMap;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrResponseFilter;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.AutoCompleteWords;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.FieldMap;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchResponseFilter;
/**
* Get a list of Profiles with last names that begin with this search term, and
@ -60,7 +59,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrResponseFilter;
* if an error occurs, return an empty result.
*/
class ProfileAutoCompleter extends AbstractAjaxResponder implements
SolrResponseFilter {
SearchResponseFilter {
private static final Log log = LogFactory
.getLog(ProfileAutoCompleter.class);
@ -71,7 +70,7 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
.singleton("http://xmlns.com/foaf/0.1/Person");
private static final String WORD_DELIMITER = "[, ]+";
private static final FieldMap RESPONSE_FIELDS = SolrQueryUtils.fieldMap()
private static final FieldMap RESPONSE_FIELDS = SearchQueryUtils.fieldMap()
.put(URI, "uri").put(NAME_RAW, "label");
private static final Syntax SYNTAX = Syntax.syntaxARQ;
@ -96,7 +95,7 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
this.externalAuthId = getStringParameter(PARAMETER_ETERNAL_AUTH_ID, "");
this.term = getStringParameter(PARAMETER_SEARCH_TERM, "");
this.searchWords = SolrQueryUtils.parseForAutoComplete(term,
this.searchWords = SearchQueryUtils.parseForAutoComplete(term,
WORD_DELIMITER);
// TODO This seems to expose the matching property and mechanism too
@ -123,7 +122,7 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
SearchQuery query = buildSearchQuery();
SearchResponse queryResponse = executeSearchQuery(query);
List<Map<String, String>> maps = SolrQueryUtils
List<Map<String, String>> maps = SearchQueryUtils
.parseAndFilterResponse(queryResponse, RESPONSE_FIELDS,
this, 30);
@ -142,7 +141,7 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
SearchQuery q = ApplicationUtils.instance().getSearchEngine().createQuery();
q.addFields(NAME_RAW, URI);
q.addSortField(NAME_LOWERCASE_SINGLE_VALUED, Order.ASC);
q.addFilterQuery(SolrQueryUtils.assembleConjunctiveQuery(RDFTYPE,
q.addFilterQuery(SearchQueryUtils.assembleConjunctiveQuery(RDFTYPE,
profileTypes, OR));
q.setStart(0);
q.setRows(10000);
@ -152,8 +151,8 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
private SearchResponse executeSearchQuery(SearchQuery query)
throws SearchEngineException {
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
return solr.query(query);
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
return search.query(query);
}
/**

View file

@ -1,13 +1,14 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ajax;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.AC_NAME_STEMMED;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_LOWERCASE_SINGLE_VALUED;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_RAW;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_UNSTEMMED;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.RDFTYPE;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.URI;
import static edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils.Conjunction.OR;
import static edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils.Conjunction.OR;
import java.io.IOException;
import java.util.List;
@ -29,9 +30,9 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineExcepti
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery.Order;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResponse;
import edu.cornell.mannlib.vitro.webapp.utils.solr.AutoCompleteWords;
import edu.cornell.mannlib.vitro.webapp.utils.solr.FieldMap;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.AutoCompleteWords;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.FieldMap;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
/**
* Get the basic auto-complete info for the profile selection.
@ -41,7 +42,7 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
private static final Log log = LogFactory.getLog(BasicProfilesGetter.class);
private static final String WORD_DELIMITER = "[, ]+";
private static final FieldMap RESPONSE_FIELDS = SolrQueryUtils
private static final FieldMap RESPONSE_FIELDS = SearchQueryUtils
.fieldMap().put(URI, "uri").put(NAME_RAW, "label")
.put("bogus", "classLabel").put("bogus", "imageUrl");
@ -58,7 +59,7 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
super(servlet, vreq, resp);
this.term = getStringParameter(PARAMETER_SEARCH_TERM, "");
this.searchWords = SolrQueryUtils.parseForAutoComplete(term,
this.searchWords = SearchQueryUtils.parseForAutoComplete(term,
WORD_DELIMITER);
this.profileTypes = figureProfileTypes();
@ -69,7 +70,7 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
private List<String> figureProfileTypes() {
String typesString = ConfigurationProperties.getBean(vreq).getProperty(
PROPERTY_PROFILE_TYPES, DEFAULT_PROFILE_TYPES);
List<String> list = SolrQueryUtils.parseWords(typesString,
List<String> list = SearchQueryUtils.parseWords(typesString,
WORD_DELIMITER);
if (list.isEmpty()) {
log.error("No types configured for profile pages in "
@ -86,11 +87,11 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
}
try {
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
SearchQuery query = buildSearchQuery();
SearchResponse queryResponse = solr.query(query);
SearchResponse queryResponse = search.query(query);
List<Map<String, String>> parsed = SolrQueryUtils
List<Map<String, String>> parsed = SearchQueryUtils
.parseResponse(queryResponse, RESPONSE_FIELDS);
String response = assembleJsonResponse(parsed);
@ -106,7 +107,7 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
SearchQuery q = ApplicationUtils.instance().getSearchEngine().createQuery();
q.addFields(NAME_RAW, URI);
q.addSortField(NAME_LOWERCASE_SINGLE_VALUED, Order.ASC);
q.addFilterQuery(SolrQueryUtils.assembleConjunctiveQuery(RDFTYPE, profileTypes, OR));
q.addFilterQuery(SearchQueryUtils.assembleConjunctiveQuery(RDFTYPE, profileTypes, OR));
q.setStart(0);
q.setRows(30);
q.setQuery(searchWords.assembleQuery(NAME_UNSTEMMED, AC_NAME_STEMMED));

View file

@ -22,7 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResults;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual;
/**
@ -138,19 +138,19 @@ public class IndividualListController extends FreemarkerHttpServlet {
//TODO: Remove and update reference within JsonServlet
public static String getAlphaParameter(VitroRequest request){
return SolrQueryUtils.getAlphaParameter(request);
return SearchQueryUtils.getAlphaParameter(request);
}
//TODO: Remove and update reference within JsonServlet
public static int getPageParameter(VitroRequest request) {
return SolrQueryUtils.getPageParameter(request);
return SearchQueryUtils.getPageParameter(request);
}
public static IndividualListResults getResultsForVClass(String vclassURI, int page, String alpha, IndividualDao indDao)
throws SearchException{
try{
List<String> classUris = Collections.singletonList(vclassURI);
IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteVClassQuery(classUris, alpha, page, INDIVIDUALS_PER_PAGE, indDao);
IndividualListQueryResults results = SearchQueryUtils.buildAndExecuteVClassQuery(classUris, alpha, page, INDIVIDUALS_PER_PAGE, indDao);
return getResultsForVClassQuery(results, page, INDIVIDUALS_PER_PAGE, alpha);
} catch (SearchEngineException e) {
String msg = "An error occurred retrieving results for vclass query";
@ -165,7 +165,7 @@ public class IndividualListController extends FreemarkerHttpServlet {
public static IndividualListResults getResultsForVClassIntersections(List<String> vclassURIs, int page, int pageSize, String alpha, IndividualDao indDao) {
try{
IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteVClassQuery(vclassURIs, alpha, page, pageSize, indDao);
IndividualListQueryResults results = SearchQueryUtils.buildAndExecuteVClassQuery(vclassURIs, alpha, page, pageSize, indDao);
return getResultsForVClassQuery(results, page, pageSize, alpha);
} catch(Throwable th) {
log.error("Error retrieving individuals corresponding to intersection multiple classes." + vclassURIs.toString(), th);
@ -176,7 +176,7 @@ public class IndividualListController extends FreemarkerHttpServlet {
public static IndividualListResults getRandomResultsForVClass(String vclassURI, int page, int pageSize, IndividualDao indDao) {
try{
List<String> classUris = Collections.singletonList(vclassURI);
IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteRandomVClassQuery(classUris, page, pageSize, indDao);
IndividualListQueryResults results = SearchQueryUtils.buildAndExecuteRandomVClassQuery(classUris, page, pageSize, indDao);
return getResultsForVClassQuery(results, page, pageSize, "");
} catch(Throwable th) {
log.error("An error occurred retrieving random results for vclass query", th);
@ -184,10 +184,10 @@ public class IndividualListController extends FreemarkerHttpServlet {
}
}
//TODO: Get rid of this method and utilize SolrQueryUtils - currently appears to be referenced
//TODO: Get rid of this method and utilize SearchQueryUtils - currently appears to be referenced
//only within DataGetterUtils
public static long getIndividualCount(List<String> vclassUris, IndividualDao indDao) {
return SolrQueryUtils.getIndividualCount(vclassUris, indDao);
public static long getIndividualCount(List<String> vclassUris) {
return SearchQueryUtils.getIndividualCount(vclassUris);
}
private static IndividualListResults getResultsForVClassQuery(IndividualListQueryResults results, int page, int pageSize, String alpha) {

View file

@ -20,7 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResultDocumen
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
/**
* Holds the Individuals that were found in a Solr search query.
* Holds the Individuals that were found in a search query.
*
* Provides a convenience method to run the query and to find the Individuals.
*/
@ -39,9 +39,8 @@ public class IndividualListQueryResults {
IndividualDao indDao)
throws SearchEngineException {
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
SearchResponse response = null;
response = solr.query(query);
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
SearchResponse response = search.query(query);
if (response == null) {
log.debug("response from search query was null");

View file

@ -271,12 +271,11 @@ public class JSONReconcileServlet extends VitroHttpServlet {
// begin search
JSONArray resultJsonArr = new JSONArray();
// Solr
SearchQuery query = getQuery(queryVal, searchType, limit, propertiesList);
SearchResponse queryResponse = null;
if (query != null) {
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
queryResponse = solr.query(query);
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
queryResponse = search.query(query);
} else {
log.error("Query for a search was null");
}

View file

@ -26,7 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.Individual
* Does a Solr search for individuals, and uses the short view to render each of
* the results.
*/
public class GetRandomSolrIndividualsByVClass extends GetSolrIndividualsByVClass {
public class GetRandomSolrIndividualsByVClass extends GetSearchIndividualsByVClass {
private static final Log log = LogFactory
.getLog(GetRandomSolrIndividualsByVClass.class);

View file

@ -26,7 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.Individual
* Does a Solr search for individuals, and uses the short view to render each of
* the results.
*/
public class GetRenderedSolrIndividualsByVClass extends GetSolrIndividualsByVClasses {
public class GetRenderedSolrIndividualsByVClass extends GetSearchIndividualsByVClasses {
private static final Log log = LogFactory
.getLog(GetRenderedSolrIndividualsByVClass.class);

View file

@ -12,11 +12,11 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
/**
*
*/
public class GetSolrIndividualsByVClass extends JsonObjectProducer {
public class GetSearchIndividualsByVClass extends JsonObjectProducer {
private static final Log log = LogFactory
.getLog(GetSolrIndividualsByVClass.class);
.getLog(GetSearchIndividualsByVClass.class);
protected GetSolrIndividualsByVClass(VitroRequest vreq) {
protected GetSearchIndividualsByVClass(VitroRequest vreq) {
super(vreq);
}
@ -39,9 +39,9 @@ public class GetSolrIndividualsByVClass extends JsonObjectProducer {
vreq.setAttribute("displayType", vitroClassIdStr);
if ( queryType != null && queryType.equals("random")){
return JsonServlet.getRandomSolrIndividualsByVClass(vclass.getURI(), vreq, ctx);
return JsonServlet.getRandomSearchIndividualsByVClass(vclass.getURI(), vreq);
} else {
return JsonServlet.getSolrIndividualsByVClass(vclass.getURI(), vreq, ctx);
return JsonServlet.getSearchIndividualsByVClass(vclass.getURI(), vreq);
}
}

View file

@ -16,11 +16,11 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
* Accepts multiple vclasses and returns individuals which correspond to the
* intersection of those classes (i.e. have all those types)
*/
public class GetSolrIndividualsByVClasses extends JsonObjectProducer {
public class GetSearchIndividualsByVClasses extends JsonObjectProducer {
private static final Log log = LogFactory
.getLog(GetSolrIndividualsByVClasses.class);
.getLog(GetSearchIndividualsByVClasses.class);
public GetSolrIndividualsByVClasses(VitroRequest vreq) {
public GetSearchIndividualsByVClasses(VitroRequest vreq) {
super(vreq);
}
@ -45,7 +45,7 @@ public class GetSolrIndividualsByVClasses extends JsonObjectProducer {
throw new Exception("parameter vclassId URI parameter expected ");
}
List<String> vclassIds = Arrays.asList(vitroClassIdStr);
return JsonServlet.getSolrIndividualsByVClasses(vclassIds, vreq, ctx);
return JsonServlet.getSearchIndividualsByVClasses(vclassIds, vreq);
}
}

View file

@ -3,12 +3,9 @@
package edu.cornell.mannlib.vitro.webapp.controller.json;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -22,9 +19,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResultsUtils;
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResults;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResultsUtils;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils;
@ -62,13 +58,13 @@ public class JsonServlet extends VitroHttpServlet {
throw new IllegalArgumentException("The call invoked deprecated classes " +
"and the parameter for this call appeared nowhere in the code base, " +
"so it was removed in May, 2012.");
}else if( vreq.getParameter("getSolrIndividualsByVClass") != null ){
new GetSolrIndividualsByVClass(vreq).process(resp);
}else if( vreq.getParameter("getSearchIndividualsByVClass") != null ){
new GetSearchIndividualsByVClass(vreq).process(resp);
}else if( vreq.getParameter("getVClassesForVClassGroup") != null ){
new GetVClassesForVClassGroup(vreq).process(resp);
} else if( vreq.getParameter("getSolrIndividualsByVClasses") != null ){
} else if( vreq.getParameter("getSearchIndividualsByVClasses") != null ){
log.debug("AJAX request to retrieve individuals by vclasses");
new GetSolrIndividualsByVClasses(vreq).process(resp);
new GetSearchIndividualsByVClasses(vreq).process(resp);
} else if( vreq.getParameter("getDataForPage") != null ){
throw new IllegalArgumentException("The call invoked deprecated classes " +
"and the parameter for this call appeared nowhere in the code base, " +
@ -84,27 +80,27 @@ public class JsonServlet extends VitroHttpServlet {
}
public static JSONObject getSolrIndividualsByVClass(String vclassURI, HttpServletRequest req, ServletContext context) throws Exception {
public static JSONObject getSearchIndividualsByVClass(String vclassURI, HttpServletRequest req) throws Exception {
List<String> vclassURIs = Collections.singletonList(vclassURI);
VitroRequest vreq = new VitroRequest(req);
IndividualListResults vcResults = getSolrVClassIntersectionResults(vclassURIs, vreq, context);
IndividualListResults vcResults = getSearchVClassIntersectionResults(vclassURIs, vreq);
//last parameter indicates single vclass instead of multiple vclasses
return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, false);
}
public static JSONObject getSolrIndividualsByVClasses(List<String> vclassURIs, HttpServletRequest req, ServletContext context) throws Exception {
public static JSONObject getSearchIndividualsByVClasses(List<String> vclassURIs, HttpServletRequest req) throws Exception {
VitroRequest vreq = new VitroRequest(req);
log.debug("Retrieve solr results for vclasses" + vclassURIs.toString());
IndividualListResults vcResults = getSolrVClassIntersectionResults(vclassURIs, vreq, context);
log.debug("Results returned from Solr for " + vclassURIs.toString() + " are of size " + vcResults.getTotalCount());
log.debug("Retrieve search results for vclasses" + vclassURIs.toString());
IndividualListResults vcResults = getSearchVClassIntersectionResults(vclassURIs, vreq);
log.debug("Results returned from search engine for " + vclassURIs.toString() + " are of size " + vcResults.getTotalCount());
return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, true);
}
//Including version for Solr query for Vclass Intersections
private static IndividualListResults getSolrVClassIntersectionResults(List<String> vclassURIs, VitroRequest vreq, ServletContext context){
log.debug("Retrieving Solr intersection results for " + vclassURIs.toString());
//Including version for search query for Vclass Intersections
private static IndividualListResults getSearchVClassIntersectionResults(List<String> vclassURIs, VitroRequest vreq){
log.debug("Retrieving search intersection results for " + vclassURIs.toString());
String alpha = IndividualListController.getAlphaParameter(vreq);
int page = IndividualListController.getPageParameter(vreq);
log.debug("Alpha and page parameters are " + alpha + " and " + page);
@ -128,17 +124,17 @@ public class JsonServlet extends VitroHttpServlet {
return value;
}
public static JSONObject getRandomSolrIndividualsByVClass(String vclassURI, HttpServletRequest req, ServletContext context) throws Exception {
public static JSONObject getRandomSearchIndividualsByVClass(String vclassURI, HttpServletRequest req) throws Exception {
VitroRequest vreq = new VitroRequest(req);
IndividualListResults vcResults = getRandomSolrVClassResults(vclassURI, vreq, context);
IndividualListResults vcResults = getRandomSearchVClassResults(vclassURI, vreq);
//last parameter indicates single vclass instead of multiple vclasses
return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, false);
}
//Including version for Random Solr query for Vclass Intersections
private static IndividualListResults getRandomSolrVClassResults(String vclassURI, VitroRequest vreq, ServletContext context){
log.debug("Retrieving random Solr intersection results for " + vclassURI);
private static IndividualListResults getRandomSearchVClassResults(String vclassURI, VitroRequest vreq){
log.debug("Retrieving random search intersection results for " + vclassURI);
int page = IndividualListController.getPageParameter(vreq);
int pageSize = Integer.parseInt(vreq.getParameter("pageSize"));

View file

@ -56,15 +56,15 @@ import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
* The cache is updated asynchronously by the thread RebuildGroupCacheThread.
* A synchronous rebuild can be performed with VClassGroupCache.doSynchronousRebuild()
*
* This class should handle the condition where Solr is not available.
* This class should handle the condition where the search engine is not available.
* It will not throw an exception but it will return a empty list of classes
* or class groups.
*
* VClassGroupCache.doSynchronousRebuild() and the RebuildGroupCacheThread will try
* to connect to the Solr server a couple of times and then give up.
* to connect to the search engine a couple of times and then give up.
*
* As of VIVO release 1.4, the counts come from the Solr index. If the
* solr index is not built or if there were problems building the index,
* As of VIVO release 1.4, the counts come from the search index. If the
* search index is not built or if there were problems building the index,
* the class counts from VClassGroupCache will be incorrect.
*/
public class VClassGroupCache implements IndexingEventListener {
@ -185,7 +185,7 @@ public class VClassGroupCache implements IndexingEventListener {
}
public void doSynchronousRebuild(){
//try to rebuild a couple times since the Solr server may not yet be up.
//try to rebuild a couple times since the search engine may not yet be up.
int attempts = 0;
int maxTries = 3;
@ -194,7 +194,7 @@ public class VClassGroupCache implements IndexingEventListener {
while( attempts < maxTries ){
try {
attempts++;
rebuildCacheUsingSolr(this);
rebuildCacheUsingSearch(this);
break;
} catch (SearchEngineException e) {
exception = e;
@ -244,17 +244,15 @@ public class VClassGroupCache implements IndexingEventListener {
/**
* Method that rebuilds the cache. This will use a WebappDaoFactory,
* a SolrSever and maybe a ProhibitedFromSearch from the cache.context.
* a SearchEngine and maybe a ProhibitedFromSearch from the cache.context.
*
* If ProhibitedFromSearch is not found in the context, that will be skipped.
*
* @throws SearchEngineException if there are problems with the Solr server.
*/
protected static void rebuildCacheUsingSolr( VClassGroupCache cache ) throws SearchEngineException{
protected static void rebuildCacheUsingSearch( VClassGroupCache cache ) throws SearchEngineException{
long start = System.currentTimeMillis();
WebappDaoFactory wdFactory = ModelAccess.on(cache.context).getWebappDaoFactory();
SearchEngine solrServer = ApplicationUtils.instance().getSearchEngine();
SearchEngine searchEngine = ApplicationUtils.instance().getSearchEngine();
VitroFilters vFilters = VitroFilterUtils.getPublicFilter(cache.context);
VClassGroupDao vcgDao = new WebappDaoFactoryFiltering(wdFactory, vFilters).getVClassGroupDao();
@ -263,7 +261,7 @@ public class VClassGroupCache implements IndexingEventListener {
INCLUDE_UNINSTANTIATED, DONT_INCLUDE_INDIVIDUAL_COUNT);
removeClassesHiddenFromSearch(groups, cache.context);
addCountsUsingSolr(groups, solrServer);
addCountsUsingSearch(groups, searchEngine);
cache.setCache(groups, classMapForGroups(groups));
log.debug("msec to build cache: " + (System.currentTimeMillis() - start));
@ -310,23 +308,23 @@ public class VClassGroupCache implements IndexingEventListener {
* Add the Individual count to classes in groups.
* @throws SearchEngineException
*/
protected static void addCountsUsingSolr(List<VClassGroup> groups, SearchEngine solrServer)
protected static void addCountsUsingSearch(List<VClassGroup> groups, SearchEngine searchEngine)
throws SearchEngineException {
if( groups == null || solrServer == null )
if( groups == null || searchEngine == null )
return;
for( VClassGroup group : groups){
addClassCountsToGroup(group, solrServer);
addClassCountsToGroup(group, searchEngine);
}
}
protected static void addClassCountsToGroup(VClassGroup group, SearchEngine solrServer)
protected static void addClassCountsToGroup(VClassGroup group, SearchEngine searchEngine)
throws SearchEngineException {
if( group == null ) return;
String groupUri = group.getURI();
String facetOnField = VitroSearchTermNames.RDFTYPE;
SearchQuery query = ApplicationUtils.instance().getSearchEngine().createQuery().
SearchQuery query = searchEngine.createQuery().
setRows(0).
setQuery(VitroSearchTermNames.CLASSGROUP_URI + ":" + groupUri ).
setFaceting(true). //facet on type to get counts for classes in classgroup
@ -335,7 +333,7 @@ public class VClassGroupCache implements IndexingEventListener {
log.debug("query: " + query);
SearchResponse rsp = solrServer.query(query);
SearchResponse rsp = searchEngine.query(query);
//Get individual count
long individualCount = rsp.getResults().getNumFound();
@ -419,7 +417,7 @@ public class VClassGroupCache implements IndexingEventListener {
setWorkLevel(WorkLevel.WORKING);
rebuildRequested = false;
try {
rebuildCacheUsingSolr( cache );
rebuildCacheUsingSearch( cache );
log.debug("rebuildGroupCacheThread.run() -- rebuilt cache ");
failedAttempts = 0;
delay = 100;
@ -427,7 +425,7 @@ public class VClassGroupCache implements IndexingEventListener {
failedAttempts++;
if( failedAttempts >= maxFailedAttempts ){
log.error("Could not build VClassGroupCache. " +
"Could not connect with Solr after " +
"Could not connect with the search engine after " +
failedAttempts + " attempts.", e.getCause());
rebuildRequested = false;
failedAttempts = 0;
@ -435,7 +433,7 @@ public class VClassGroupCache implements IndexingEventListener {
}else{
rebuildRequested = true;
delay = (int) (( Math.pow(2, failedAttempts) ) * 1000);
log.debug("Could not connect with Solr, will attempt " +
log.debug("Could not connect with the search engine, will attempt " +
"again in " + delay + " msec.");
}
}catch(Exception ex){

View file

@ -26,16 +26,16 @@ import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
import edu.cornell.mannlib.vitro.webapp.utils.fields.FieldUtils;
/*
* This runs a solr query to get individuals of a certain class instead of relying on the dao classes.
* This runs a search query to get individuals of a certain class instead of relying on the dao classes.
* Also it gets individuals that belong to the most specific type(s) specified.
*/
public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions implements FieldOptions {
private Log log = LogFactory.getLog(IndividualsViaSolrQueryOptions.class);
public class IndividualsViaSearchQueryOptions extends IndividualsViaVClassOptions implements FieldOptions {
private Log log = LogFactory.getLog(IndividualsViaSearchQueryOptions.class);
private String subjectUri;
private String predicateUri;
private String objectUri;
public IndividualsViaSolrQueryOptions(String inputSubjectUri, String inputPredicateUri, String inputObjectUri, String ... vclassURIs) throws Exception {
public IndividualsViaSearchQueryOptions(String inputSubjectUri, String inputPredicateUri, String inputObjectUri, String ... vclassURIs) throws Exception {
super(vclassURIs);
this.subjectUri = inputSubjectUri;
this.predicateUri = inputPredicateUri;
@ -46,10 +46,10 @@ public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions
protected Map<String,Individual> getIndividualsForClass(String vclassURI, WebappDaoFactory wDaoFact ){
Map<String, Individual> individualMap = new HashMap<String, Individual>();
try {
SearchEngine solrServer = ApplicationUtils.instance().getSearchEngine();
SearchEngine searchEngine = ApplicationUtils.instance().getSearchEngine();
//solr query for type count.
SearchQuery query = solrServer.createQuery();
//search query for type count.
SearchQuery query = searchEngine.createQuery();
if( VitroVocabulary.OWL_THING.equals( vclassURI )){
query.setQuery( "*:*" );
}else{
@ -59,7 +59,7 @@ public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions
.setRows(1000);
query.addFields(VitroSearchTermNames.URI); // fields to retrieve
SearchResponse rsp = solrServer.query(query);
SearchResponse rsp = searchEngine.query(query);
SearchResultDocumentList docs = rsp.getResults();
long found = docs.getNumFound();
if(found > 0) {
@ -75,13 +75,13 @@ public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions
}
}
catch(Exception ex) {
log.error("An error occurred retrieving the individual solr query resutls", ex);
log.error("An error occurred retrieving the individual search resutls", ex);
}
}
}
} catch(Exception ex) {
log.error("Error occurred in executing solr query ", ex);
log.error("Error occurred in executing search query ", ex);
}
return individualMap;
}

View file

@ -175,7 +175,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
private boolean tooManyRangeOptions(VitroRequest vreq, HttpSession session ) throws SearchEngineException {
List<VClass> rangeTypes = getRangeTypes(vreq);
SearchEngine solrServer = ApplicationUtils.instance().getSearchEngine();
SearchEngine searchEngine = ApplicationUtils.instance().getSearchEngine();
List<String> types = new ArrayList<String>();
for (VClass vclass : rangeTypes) {
@ -191,15 +191,15 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
long count = 0;
for( String type:types){
//solr query for type count.
SearchQuery query = solrServer.createQuery();
//search query for type count.
SearchQuery query = searchEngine.createQuery();
if( VitroVocabulary.OWL_THING.equals( type )){
query.setQuery( "*:*" );
}else{
query.setQuery( VitroSearchTermNames.RDFTYPE + ":" + type);
}
query.setRows(0);
SearchResponse rsp = solrServer.query(query);
SearchResponse rsp = searchEngine.query(query);
SearchResultDocumentList docs = rsp.getResults();
long found = docs.getNumFound();
count = count + found;
@ -552,7 +552,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
}
//TODO: find out if there are any individuals in the classes of objectTypes
formSpecificData.put("rangeIndividualsExist", rangeIndividualsExist(session,types) );
formSpecificData.put("rangeIndividualsExist", rangeIndividualsExist(types) );
formSpecificData.put("sparqlForAcFilter", getSparqlForAcFilter(vreq));
if(customErrorMessages != null && !customErrorMessages.isEmpty()) {
@ -562,18 +562,17 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
editConfiguration.setFormSpecificData(formSpecificData);
}
private Object rangeIndividualsExist(HttpSession session, List<VClass> types) throws SearchEngineException {
SearchEngine solrServer = ApplicationUtils.instance().getSearchEngine();
private Object rangeIndividualsExist(List<VClass> types) throws SearchEngineException {
SearchEngine searchEngine = ApplicationUtils.instance().getSearchEngine();
boolean rangeIndividualsFound = false;
for( VClass type:types){
//solr for type count.
SearchQuery query =ApplicationUtils.instance().getSearchEngine().createQuery();
//search for type count.
SearchQuery query = searchEngine.createQuery();
query.setQuery( VitroSearchTermNames.RDFTYPE + ":" + type.getURI());
query.setRows(0);
SearchResponse rsp = solrServer.query(query);
SearchResponse rsp = searchEngine.query(query);
SearchResultDocumentList docs = rsp.getResults();
if( docs.getNumFound() > 0 ){
rangeIndividualsFound = true;

View file

@ -18,7 +18,7 @@ public class ProcessDataGetterN3Map {
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessClassGroupDataGetterN3");
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessIndividualsForClassesDataGetterN3");
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessFixedHTMLN3");
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSolrIndividualsDataGetterN3");
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSearchIndividualsDataGetterN3");
return map;
}

View file

@ -24,11 +24,11 @@ import com.hp.hpl.jena.rdf.model.Resource;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
//Returns the appropriate n3 based on data getter
public class ProcessSolrIndividualsDataGetterN3 extends ProcessDataGetterAbstract {
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter";
public class ProcessSearchIndividualsDataGetterN3 extends ProcessDataGetterAbstract {
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter";
private Log log = LogFactory.getLog(ProcessFixedHTMLN3.class);
public ProcessSolrIndividualsDataGetterN3(){
public ProcessSearchIndividualsDataGetterN3(){
}
//Pass in variable that represents the counter

View file

@ -30,9 +30,9 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResponse;
import edu.cornell.mannlib.vitro.webapp.utils.solr.FieldMap;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrResultsParser;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.FieldMap;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchResultsParser;
/**
* Assist in cache management for individual profile pages.
@ -41,7 +41,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrResultsParser;
*
* Only works for users who are not logged in.
*
* The Solr index must be configured to keep an ETAG on each individual's
* The search index must be configured to keep an ETAG on each individual's
* record. The ETAG is a hash of the record's content and is updated each time
* the individual is re-indexed.
*
@ -59,10 +59,10 @@ import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrResultsParser;
* generated, with a Cache-Control header that should prevent the cache from
* storing that response.
*
* If the requesting user is not logged in, this filter will ask Solr for the
* ETAG on the requested individual. If it is the same as the ETAG supplied by
* the cache in the request, then the response is 304 Not Modified. Otherwise, a
* fresh response is generated.
* If the requesting user is not logged in, this filter will ask the search
* engine for the ETAG on the requested individual. If it is the same as the
* ETAG supplied by the cache in the request, then the response is 304 Not
* Modified. Otherwise, a fresh response is generated.
*
* An unconditional request may mean that there is no external cache, or that
* the cache doesn't have a copy of this particular page.
@ -77,7 +77,7 @@ public class CachingResponseFilter implements Filter {
private static final String PROPERTY_ENABLE_CACHING = "http.createCacheHeaders";
private static final String ETAG_FIELD = "etag";
private static final FieldMap parserFieldMap = SolrQueryUtils.fieldMap()
private static final FieldMap parserFieldMap = SearchQueryUtils.fieldMap()
.put(ETAG_FIELD, ETAG_FIELD);
private ServletContext ctx;
@ -241,18 +241,18 @@ public class CachingResponseFilter implements Filter {
}
/**
* Ask Solr whether it has an ETAG for this URI.
* Ask the search engine whether it has an ETAG for this URI.
*/
private String findEtagForIndividual(String individualUri) {
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
SearchQuery query = solr.createQuery("URI:" + individualUri)
.addFields(ETAG_FIELD);
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
SearchQuery query = search.createQuery("URI:" + individualUri).addFields(
ETAG_FIELD);
try {
SearchResponse response = solr.query(query);
List<Map<String, String>> maps = new SolrResultsParser(response,
SearchResponse response = search.query(query);
List<Map<String, String>> maps = new SearchResultsParser(response,
parserFieldMap).parse();
log.debug("Solr response for '" + query.getQuery() + "' was "
log.debug("Search response for '" + query.getQuery() + "' was "
+ maps);
if (maps.isEmpty()) {
@ -262,14 +262,14 @@ public class CachingResponseFilter implements Filter {
}
} catch (SearchEngineException e) {
log.warn(
"Solr query '" + query.getQuery() + "' threw an exception",
"Search query '" + query.getQuery() + "' threw an exception",
e);
return null;
}
}
/**
* The ETAG from the Solr index is not specific enough, since we may have
* The ETAG from the search index is not specific enough, since we may have
* different versions for different languages. Add the Locales from the
* request to make it unique.
*/

View file

@ -74,8 +74,8 @@ public class AutocompleteController extends VitroAjaxController {
}
log.debug("query for '" + qtxt +"' is " + query.toString());
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
SearchResponse queryResponse = solr.query(query);
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
SearchResponse queryResponse = search.query(query);
if ( queryResponse == null) {
log.error("Query response for a search was null");
@ -254,7 +254,7 @@ public class AutocompleteController extends VitroAjaxController {
}
private String escapeWhitespaceInQueryString(String queryStr) {
// Solr wants whitespace to be escaped with a backslash
// The search engine wants whitespace to be escaped with a backslash
return queryStr.replaceAll("\\s+", "\\\\ ");
}

View file

@ -55,10 +55,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.searchresult.Individu
import edu.ucsf.vitro.opensocial.OpenSocialManager;
/**
* Paged search controller that uses Solr
*
* @author bdc34, rjy7
*
* Paged search controller that uses the search engine
*/
public class PagedSearchController extends FreemarkerHttpServlet {
@ -170,14 +167,14 @@ public class PagedSearchController extends FreemarkerHttpServlet {
}
SearchQuery query = getQuery(queryText, hitsPerPage, startIndex, vreq);
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
SearchResponse response = null;
try {
response = solr.query(query);
response = search.query(query);
} catch (Exception ex) {
String msg = makeBadSearchMessage(queryText, ex.getMessage(), vreq);
log.error("could not run Solr query",ex);
log.error("could not run search query",ex);
return doFailedSearch(msg, queryText, format, vreq);
}
@ -467,7 +464,7 @@ public class PagedSearchController extends FreemarkerHttpServlet {
}
private SearchQuery getQuery(String queryText, int hitsPerPage, int startIndex, VitroRequest vreq) {
// Lowercase the search term to support wildcard searches: Solr applies no text
// Lowercase the search term to support wildcard searches: The search engine applies no text
// processing to a wildcard search term.
SearchQuery query = ApplicationUtils.instance().getSearchEngine().createQuery(queryText);

View file

@ -11,14 +11,14 @@ import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSearchDocument;
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
class IndexWorkerThread extends VitroBackgroundThread{
private static final Log log = LogFactory.getLog(IndexWorkerThread.class);
protected final int threadNum;
protected IndividualToSolrDocument individualToSolrDoc;
protected IndividualToSearchDocument individualToSolrDoc;
protected final IndexerIface indexer;
protected final Iterator<Individual> individualsToIndex;
protected boolean stopRequested = false;

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.search.solr;
import java.io.IOException;
import java.util.HashSet;
import org.apache.commons.logging.Log;
@ -19,16 +18,16 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResponse;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResultDocumentList;
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSearchDocument;
public class SolrIndexer implements IndexerIface {
private final static Log log = LogFactory.getLog(SolrIndexer.class);
public class SearchIndexer implements IndexerIface {
private final static Log log = LogFactory.getLog(SearchIndexer.class);
protected SearchEngine server;
protected boolean indexing;
protected HashSet<String> urisIndexed;
protected IndividualToSolrDocument individualToSolrDoc;
protected IndividualToSearchDocument individualToSearchDoc;
/**
* System is shutting down if true.
@ -37,7 +36,7 @@ public class SolrIndexer implements IndexerIface {
/**
* This records when a full re-index starts so that once it is done
* all the documents on the Solr service that are earlier than the
* all the documents in the search index that are earlier than the
* reindexStart can be removed.
*/
protected long reindexStart = 0L;
@ -49,15 +48,15 @@ public class SolrIndexer implements IndexerIface {
*/
protected boolean doingFullIndexRebuild = false;
public SolrIndexer( SearchEngine server, IndividualToSolrDocument indToDoc){
public SearchIndexer( SearchEngine server, IndividualToSearchDocument indToDoc){
this.server = server;
this.individualToSolrDoc = indToDoc;
this.individualToSearchDoc = indToDoc;
}
@Override
public void index(Individual ind) throws IndexingException {
if( ! indexing )
throw new IndexingException("SolrIndexer: must call " +
throw new IndexingException("SearchIndexer: must call " +
"startIndexing() before index().");
if( ind == null ) {
@ -70,20 +69,20 @@ public class SolrIndexer implements IndexerIface {
log.debug("already indexed " + ind.getURI() );
return;
}else{
SearchInputDocument solrDoc = null;
SearchInputDocument doc = null;
synchronized(this){
urisIndexed.add(ind.getURI());
}
log.debug("indexing " + ind.getURI());
solrDoc = individualToSolrDoc.translate(ind);
doc = individualToSearchDoc.translate(ind);
if( solrDoc != null){
if( doc != null){
if( log.isDebugEnabled()){
log.info("boost for " + ind.getName() + " is " + solrDoc.getDocumentBoost());
log.debug( solrDoc.toString() );
log.info("boost for " + ind.getName() + " is " + doc.getDocumentBoost());
log.debug( doc.toString() );
}
server.add( solrDoc );
server.add( doc );
log.debug("Added docs to server.");
}else{
log.debug("removing from index " + ind.getURI());
@ -110,7 +109,7 @@ public class SolrIndexer implements IndexerIface {
public void removeFromIndex(String uri) throws IndexingException {
if( uri != null ){
try {
server.deleteById(individualToSolrDoc.getIdForUri(uri));
server.deleteById(individualToSearchDoc.getIdForUri(uri));
log.debug("deleted " + " " + uri);
} catch (SearchEngineException e) {
log.error( "could not delete individual " + uri, e);
@ -121,7 +120,7 @@ public class SolrIndexer implements IndexerIface {
@Override
public synchronized void startIndexing() throws IndexingException {
if( indexing)
log.debug("SolrIndexer.startIndexing() Indexing in progress, waiting for completion...");
log.debug("SearchIndexer.startIndexing() Indexing in progress, waiting for completion...");
while( indexing && ! shutdownRequested ){ //wait for indexing to end.
try{ wait( 250 ); }
catch(InterruptedException ex){}
@ -137,7 +136,7 @@ public class SolrIndexer implements IndexerIface {
public void abortIndexingAndCleanUp() {
shutdownRequested = true;
try{
individualToSolrDoc.shutdown();
individualToSearchDoc.shutdown();
}catch(Exception e){
if( log != null)
log.debug(e,e);
@ -159,8 +158,8 @@ public class SolrIndexer implements IndexerIface {
server.commit();
} catch (Throwable e) {
if( ! shutdownRequested ){
log.debug("could not commit to solr server, " +
"this should not be a problem since solr will do autocommit");
log.debug("could not commit to the search engine, " +
"this should not be a problem since the search engine will do autocommit");
}
}
indexing = false;
@ -213,7 +212,7 @@ public class SolrIndexer implements IndexerIface {
return true;
}
} catch (SearchEngineException e) {
log.error("Could not connect to solr server" ,e.getCause());
log.error("Could not connect to the search engine." ,e.getCause());
}
return false;
}

View file

@ -37,7 +37,7 @@ public class ContextNodeFields implements DocumentModifier{
protected RDFServiceFactory rdfServiceFactory;
/**
* Construct this with a model to query when building Solr Documents and
* Construct this with a model to query when building search documents and
* a list of the SPARQL queries to run.
*/
protected ContextNodeFields(List<String> queries, RDFServiceFactory rdfServiceFactory){
@ -73,10 +73,10 @@ public class ContextNodeFields implements DocumentModifier{
/**
* this method gets values that will be added to ALLTEXT
* field of solr Document for each individual.
* field of the search index Document for each individual.
*
* @param individual
* @return StringBuffer with text values to add to ALLTEXT field of solr Document.
* @return StringBuffer with text values to add to ALLTEXT field of the search index Document.
*/
protected StringBuffer executeQueryForValues( Individual individual, Collection<String> queries){
/* execute all the queries on the list and concat the values to add to all text */

View file

@ -1,7 +1,7 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding;
import static edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument.DONT_EXCLUDE;
import static edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSearchDocument.DONT_EXCLUDE;
import java.util.List;

View file

@ -29,9 +29,9 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResultDocumen
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
public class IndividualToSolrDocument {
public class IndividualToSearchDocument {
public static final Log log = LogFactory.getLog(IndividualToSolrDocument.class.getName());
public static final Log log = LogFactory.getLog(IndividualToSearchDocument.class.getName());
public static VitroSearchTermNames term = new VitroSearchTermNames();
@ -41,7 +41,7 @@ public class IndividualToSolrDocument {
protected List<SearchIndexExcluder> excludes;
public IndividualToSolrDocument(List<SearchIndexExcluder> excludes, List<DocumentModifier> docModifiers){
public IndividualToSearchDocument(List<SearchIndexExcluder> excludes, List<DocumentModifier> docModifiers){
this.excludes = excludes;
this.documentModifiers = docModifiers;
}
@ -302,12 +302,12 @@ public class IndividualToSolrDocument {
doc.addField(term.NAME_RAW, value);
doc.addField(term.NAME_LOWERCASE_SINGLE_VALUED,value);
// NAME_RAW will be copied by solr into the following fields:
// NAME_RAW will be copied by the search engine into the following fields:
// NAME_LOWERCASE, NAME_UNSTEMMED, NAME_STEMMED, NAME_PHONETIC, AC_NAME_UNTOKENIZED, AC_NAME_STEMMED
}
public Object getIndexId(Object obj) {
throw new Error("IndiviudalToSolrDocument.getIndexId() is unimplemented");
throw new Error("IndiviudalToSearchDocument.getIndexId() is unimplemented");
}
public String getIdForUri(String uri){

View file

@ -29,13 +29,13 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalUriFinders;
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
import edu.cornell.mannlib.vitro.webapp.search.indexing.SearchReindexingListener;
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrIndexer;
import edu.cornell.mannlib.vitro.webapp.search.solr.SearchIndexer;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.DocumentModifier;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnNamespace;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnType;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnTypeNamespace;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeNonFlagVitro;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSearchDocument;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.NameBoost;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.NameFields;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.SearchIndexExcluder;
@ -100,13 +100,13 @@ public class SearchIndexerSetup implements ServletContextListener {
List<SearchIndexExcluder> searchIndexExcludesFromContext = (List<SearchIndexExcluder>) context
.getAttribute("SearchIndexExcludes");
IndividualToSolrDocument indToSolrDoc = setupTransltion(
IndividualToSearchDocument indToSolrDoc = setupTransltion(
jenaOntModel, displayModel,
RDFServiceUtils.getRDFServiceFactory(context),
modifiersFromContext, searchIndexExcludesFromContext);
/* setup solr indexer */
SolrIndexer solrIndexer = new SolrIndexer(searchEngine, indToSolrDoc);
SearchIndexer solrIndexer = new SearchIndexer(searchEngine, indToSolrDoc);
// This is where the builder gets the list of places to try to
// get objects to index. It is filtered so that non-public text
@ -151,7 +151,7 @@ public class SearchIndexerSetup implements ServletContextListener {
}
public static IndividualToSolrDocument setupTransltion(
public static IndividualToSearchDocument setupTransltion(
OntModel jenaOntModel, Model displayModel,
RDFServiceFactory rdfServiceFactory,
List<DocumentModifier> modifiersFromContext,
@ -187,6 +187,6 @@ public class SearchIndexerSetup implements ServletContextListener {
excludes.add(new ExcludeNonFlagVitro());
excludes.add(new SyncingExcludeBasedOnType(displayModel));
return new IndividualToSolrDocument(excludes, modifiers);
return new IndividualToSearchDocument(excludes, modifiers);
}
}

View file

@ -91,7 +91,7 @@ public class BrowseDataGetter extends DataGetterBase implements DataGetter {
//Get data servuice
public String getDataServiceUrl() {
return UrlBuilder.getUrl("/dataservice?getSolrIndividualsByVClass=1&vclassId=");
return UrlBuilder.getUrl("/dataservice?getSearchIndividualsByVClass=1&vclassId=");
}
private Map<String, Object> doClassAlphaDisplay( Map params, VitroRequest request, ServletContext context) throws Exception {
Map<String,Object> body = new HashMap<String,Object>();
@ -108,7 +108,7 @@ public class BrowseDataGetter extends DataGetterBase implements DataGetter {
VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(classUri);
map.put("class", new VClassTemplateModel(vclass));
JSONObject vclassRes = JsonServlet.getSolrIndividualsByVClass(vclass.getURI(), request, context);
JSONObject vclassRes = JsonServlet.getSearchIndividualsByVClass(vclass.getURI(), request);
map.put("totalCount", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("totalCount") ));
map.put("alpha", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("alpha") ));
map.put("individuals", JsonToFmModel.convertJSONArrayToList( (JSONArray) vclassRes.get("individuals") ));

View file

@ -267,10 +267,10 @@ public class DataGetterUtils {
* For page data getter conversions
*/
/**
* Get Individual count for Solr query for intersection of multiple classes
* Get Individual count for search query for intersection of multiple classes
*/
public static long getIndividualCountForIntersection(VitroRequest vreq, List<String> classUris) {
return IndividualListController.getIndividualCount(classUris, vreq.getWebappDaoFactory().getIndividualDao());
return IndividualListController.getIndividualCount(classUris);
}
//Return data getter type to be employed in display model

View file

@ -34,10 +34,10 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListCont
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResults;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual;
public class SolrIndividualsDataGetter extends DataGetterBase implements DataGetter{
public class SearchIndividualsDataGetter extends DataGetterBase implements DataGetter{
String dataGetterURI;
List<String> vclassUris = null;
String saveToVar;
@ -45,14 +45,14 @@ public class SolrIndividualsDataGetter extends DataGetterBase implements DataGet
ServletContext context;
final static Log log = LogFactory.getLog(SolrIndividualsDataGetter.class);
final static Log log = LogFactory.getLog(SearchIndividualsDataGetter.class);
//default template
private final static String defaultTemplate = "menupage--defaultSolrIndividuals.ftl";
/**
* Constructor with display model and data getter URI that will be called by reflection.
*/
public SolrIndividualsDataGetter(VitroRequest vreq, Model displayModel, String dataGetterURI){
public SearchIndividualsDataGetter(VitroRequest vreq, Model displayModel, String dataGetterURI){
this.configure(vreq, displayModel,dataGetterURI);
}
@ -170,8 +170,8 @@ public class SolrIndividualsDataGetter extends DataGetterBase implements DataGet
private void populateSolrQueryResults(VClass vclass, Map<String, Object> body) {
try {
String alpha = SolrQueryUtils.getAlphaParameter(vreq);
int page = SolrQueryUtils.getPageParameter(vreq);
String alpha = SearchQueryUtils.getAlphaParameter(vreq);
int page = SearchQueryUtils.getPageParameter(vreq);
IndividualListResults vcResults = IndividualListController.getResultsForVClass(
vclass.getURI(),
page,

View file

@ -1,6 +1,6 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.solr;
package edu.cornell.mannlib.vitro.webapp.utils.searchengine;
import java.util.ArrayList;
import java.util.Collections;
@ -27,15 +27,16 @@ public class AutoCompleteWords {
private final String partialWord;
/**
* Package-access. Use SolrQueryUtils.parseForAutoComplete() to create an
* Package-access. Use SearchQueryUtils.parseForAutoComplete() to create an
* instance.
*/
AutoCompleteWords(String searchTerm, String delimiterPattern) {
this.searchTerm = searchTerm;
this.searchTerm = (searchTerm == null) ? "" : searchTerm;
this.delimiterPattern = delimiterPattern;
List<String> termWords = figureTermWords();
if (termWords.isEmpty() || this.searchTerm.endsWith(" ")) {
if (termWords.isEmpty()
|| this.searchTerm.matches(".*" + delimiterPattern)) {
this.completeWords = termWords;
this.partialWord = null;
} else {

View file

@ -1,17 +1,17 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.solr;
package edu.cornell.mannlib.vitro.webapp.utils.searchengine;
import java.util.HashMap;
import java.util.Map;
/**
* A builder object that can assemble a map of Solr field names to JSON field
* names.
* A builder object that can assemble a map of search result field names to JSON
* field names.
*
* Use like this:
*
* m = SolrQueryUtils.fieldMap().row("this", "that").row("2nd", "row").map();
* m = SearchQueryUtils.fieldMap().put("this", "that").put("2nd", "row").map();
*
*/
public class FieldMap {
@ -20,14 +20,15 @@ public class FieldMap {
/**
* Add a row to the map
*/
public FieldMap put(String solrFieldName, String jsonFieldName) {
if (solrFieldName == null) {
throw new NullPointerException("solrFieldName may not be null.");
public FieldMap put(String searchResultFieldName, String jsonFieldName) {
if (searchResultFieldName == null) {
throw new NullPointerException(
"searchResultFieldName may not be null.");
}
if (jsonFieldName == null) {
throw new NullPointerException("jsonFieldName may not be null.");
}
m.put(solrFieldName, jsonFieldName);
m.put(searchResultFieldName, jsonFieldName);
return this;
}

View file

@ -1,6 +1,6 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.solr;
package edu.cornell.mannlib.vitro.webapp.utils.searchengine;
import java.util.ArrayList;
import java.util.Collection;
@ -23,12 +23,12 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResponse;
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
/**
* Some static method to help in constructing Solr queries and parsing the
* Some static methods to help in constructing search queries and parsing the
* results.
*/
public class SolrQueryUtils {
private static final Log log = LogFactory.getLog(SolrQueryUtils.class.getName());
public class SearchQueryUtils {
private static final Log log = LogFactory.getLog(SearchQueryUtils.class.getName());
public enum Conjunction {
AND, OR;
@ -48,8 +48,8 @@ public class SolrQueryUtils {
}
/**
* Create a builder object that can assemble a map of Solr field names to
* JSON field names.
* Create a builder object that can assemble a map of search result field
* names to JSON field names.
*/
public static FieldMap fieldMap() {
return new FieldMap();
@ -58,25 +58,25 @@ public class SolrQueryUtils {
/**
* Parse a response into a list of maps, one map for each document.
*
* The Solr field names in the document are replaced by json field names in
* the result, according to the fieldMap.
* The search result field names in the document are replaced by json field
* names in the result, according to the fieldMap.
*/
public static List<Map<String, String>> parseResponse(
SearchResponse queryResponse, FieldMap fieldMap) {
return new SolrResultsParser(queryResponse, fieldMap).parse();
return new SearchResultsParser(queryResponse, fieldMap).parse();
}
/**
* Parse a response into a list of maps, accepting only those maps that pass
* a filter, and only up to a maximum number of records.
*
* The Solr field names in the document are replaced by json field names in
* the result, according to the fieldMap.
* The search result field names in the document are replaced by json field
* names in the result, according to the fieldMap.
*/
public static List<Map<String, String>> parseAndFilterResponse(
SearchResponse queryResponse, FieldMap fieldMap,
SolrResponseFilter filter, int maxNumberOfResults) {
return new SolrResultsParser(queryResponse, fieldMap)
SearchResponseFilter filter, int maxNumberOfResults) {
return new SearchResultsParser(queryResponse, fieldMap)
.parseAndFilterResponse(filter, maxNumberOfResults);
}
@ -107,8 +107,7 @@ public class SolrQueryUtils {
for (String word : words) {
terms.add(buildTerm(fieldName, word));
}
String q = StringUtils.join(terms, c.joiner());
return q;
return StringUtils.join(terms, c.joiner());
}
private static String buildTerm(String fieldName, String word) {
@ -116,7 +115,8 @@ public class SolrQueryUtils {
}
/**
* Methods that can be used in multiple places, such as IndividualListController and SolrIndividualsDataGetter
* Methods that can be used in multiple places, such as
* IndividualListController and SearchIndividualsDataGetter
*/
public static String getAlphaParameter(VitroRequest request){
@ -138,13 +138,13 @@ public class SolrQueryUtils {
}
//Get count of individuals without actually getting the results
public static long getIndividualCount(List<String> vclassUris, IndividualDao indDao) {
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
SearchQuery query = solr.createQuery(makeMultiClassQuery(vclassUris));
public static long getIndividualCount(List<String> vclassUris) {
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
SearchQuery query = search.createQuery(makeMultiClassQuery(vclassUris));
query.setRows(0);
try {
SearchResponse response = null;
response = solr.query(query);
response = search.query(query);
return response.getResults().getNumFound();
} catch(Exception ex) {
log.error("An error occured in retrieving individual count", ex);
@ -181,7 +181,7 @@ public class SolrQueryUtils {
return query;
} catch (Exception ex){
log.error("Could not make Solr query",ex);
log.error("Could not make the search query",ex);
return searchEngine.createQuery();
}
}
@ -202,7 +202,7 @@ public class SolrQueryUtils {
return query;
} catch (Exception ex){
log.error("Could not make the Solr query",ex);
log.error("Could not make the search query",ex);
return searchEngine.createQuery();
}
}
@ -216,7 +216,7 @@ public class SolrQueryUtils {
}
return StringUtils.join(queryTypes, " AND ");
} catch (Exception ex){
log.error("Could not make Solr query",ex);
log.error("Could not make the search query",ex);
return "";
}
}
@ -224,9 +224,9 @@ public class SolrQueryUtils {
public static IndividualListQueryResults buildAndExecuteVClassQuery(
List<String> vclassURIs, String alpha, int page, int pageSize, IndividualDao indDao)
throws SearchEngineException {
SearchQuery query = SolrQueryUtils.getQuery(vclassURIs, alpha, page, pageSize);
SearchQuery query = SearchQueryUtils.getQuery(vclassURIs, alpha, page, pageSize);
IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao);
log.debug("Executed solr query for " + vclassURIs);
log.debug("Executed search query for " + vclassURIs);
if (results.getIndividuals().isEmpty()) {
log.debug("entities list is null for vclass " + vclassURIs);
}
@ -236,9 +236,9 @@ public class SolrQueryUtils {
public static IndividualListQueryResults buildAndExecuteRandomVClassQuery(
List<String> vclassURIs, int page, int pageSize, IndividualDao indDao)
throws SearchEngineException {
SearchQuery query = SolrQueryUtils.getRandomQuery(vclassURIs, page, pageSize);
SearchQuery query = SearchQueryUtils.getRandomQuery(vclassURIs, page, pageSize);
IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao);
log.debug("Executed solr query for " + vclassURIs);
log.debug("Executed search query for " + vclassURIs);
if (results.getIndividuals().isEmpty()) {
log.debug("entities list is null for vclass " + vclassURIs);
}

View file

@ -0,0 +1,12 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.searchengine;
import java.util.Map;
/**
* This can be used to filter the results of the search query.
*/
public interface SearchResponseFilter {
boolean accept(Map<String, String> map);
}

View file

@ -1,6 +1,6 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.solr;
package edu.cornell.mannlib.vitro.webapp.utils.searchengine;
import java.util.ArrayList;
import java.util.HashMap;
@ -15,18 +15,18 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResultDocumen
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResultDocumentList;
/**
* Parse this Solr response, creating a map of values for each document.
* Parse this search response, creating a map of values for each document.
*
* The Solr field names in the document are replaced by json field names in the
* parsed results, according to the fieldMap.
* The search response field names in the document are replaced by json field
* names in the parsed results, according to the fieldMap.
*/
public class SolrResultsParser {
private static final Log log = LogFactory.getLog(SolrResultsParser.class);
public class SearchResultsParser {
private static final Log log = LogFactory.getLog(SearchResultsParser.class);
private final SearchResponse queryResponse;
private final Map<String, String> fieldNameMapping;
public SolrResultsParser(SearchResponse queryResponse, FieldMap fieldMap) {
public SearchResultsParser(SearchResponse queryResponse, FieldMap fieldMap) {
this.queryResponse = queryResponse;
this.fieldNameMapping = fieldMap.map();
}
@ -62,7 +62,7 @@ public class SolrResultsParser {
* have parsed the entire response).
*/
public List<Map<String, String>> parseAndFilterResponse(
SolrResponseFilter filter, int maxNumberOfResults) {
SearchResponseFilter filter, int maxNumberOfResults) {
List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
if (queryResponse == null) {
@ -95,10 +95,10 @@ public class SolrResultsParser {
*/
private Map<String, String> parseSingleDocument(SearchResultDocument doc) {
Map<String, String> result = new HashMap<String, String>();
for (String solrFieldName : fieldNameMapping.keySet()) {
String jsonFieldName = fieldNameMapping.get(solrFieldName);
result.put(jsonFieldName, parseSingleValue(doc, solrFieldName));
for (String searchResultFieldName : fieldNameMapping.keySet()) {
String jsonFieldName = fieldNameMapping.get(searchResultFieldName);
result.put(jsonFieldName,
parseSingleValue(doc, searchResultFieldName));
}
return result;

View file

@ -1,12 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.solr;
import java.util.Map;
/**
* This can be used to filter the results of the Solr query.
*/
public interface SolrResponseFilter {
boolean accept(Map<String, String> map);
}

View file

@ -83,7 +83,7 @@ public class BrowseWidget extends Widget {
VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(classUri);
map.put("class", new VClassTemplateModel(vclass));
JSONObject vclassRes = JsonServlet.getSolrIndividualsByVClass(vclass.getURI(), request, context);
JSONObject vclassRes = JsonServlet.getSearchIndividualsByVClass(vclass.getURI(), request);
map.put("totalCount", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("totalCount") ));
map.put("alpha", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("alpha") ));
map.put("individuals", JsonToFmModel.convertJSONArrayToList( (JSONArray) vclassRes.get("individuals") ));

View file

@ -35,7 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
* TODO
*/
public class JsonServletTest extends AbstractTestClass {
private static final String GET_SOLR_INDIVIDUALS_BY_VCLASS = "getSolrIndividualsByVClass";
private static final String GET_SEARCH_INDIVIDUALS_BY_VCLASS = "getSearchIndividualsByVClass";
private static final String GET_VCLASSES_FOR_VCLASS_GROUP = "getVClassesForVClassGroup";
@ -51,16 +51,16 @@ public class JsonServletTest extends AbstractTestClass {
* ents_edit_head.jsp
* (there is an ents_edit.jsp, invoked from EntityEditController, which does not seem to invoke ents_edit.js)
*
* GetSolrIndividualsByVClass
* Mock out SolrServer (from SolrSetup) and IndividualDao
* GetSearchIndividualsByVClass
* Mock out search engine and IndividualDao
* invoked by BrowseDataGetter.java
* home page
* invoked by ClassGroupPageData.java
* >>>> Bring up "People" tab.
* invoked by BrowseWidget.java
*
* GetSolrIndividualsByVClasses
* Mock out SolrServer (from SolrSetup) and IndividualDao
* GetSearchIndividualsByVClasses
* Mock out search engine and IndividualDao
* invoked by IndividualsForClassesDataGetter.java
* ProcessIndividualsForClasses
* extended in vivo by ProcessInternalClasses
@ -85,7 +85,7 @@ public class JsonServletTest extends AbstractTestClass {
private WebappDaoFactoryStub wadf;
private VClassDaoStub vcDao;
private SearchEngineStub solr;
private SearchEngineStub search;
@Before
public void setup() throws ServletException {
@ -112,8 +112,8 @@ public class JsonServletTest extends AbstractTestClass {
vcDao = new VClassDaoStub();
wadf.setVClassDao(vcDao);
solr = new SearchEngineStub();
ApplicationStub.setup(new ServletContextStub(), solr);
search = new SearchEngineStub();
ApplicationStub.setup(new ServletContextStub(), search);
}
@Test
@ -163,7 +163,7 @@ public class JsonServletTest extends AbstractTestClass {
IOException {
setLoggerLevel(JsonServlet.class, Level.FATAL);
setLoggerLevel(JsonObjectProducer.class, Level.FATAL);
req.addParameter(GET_SOLR_INDIVIDUALS_BY_VCLASS, "true");
req.addParameter(GET_SEARCH_INDIVIDUALS_BY_VCLASS, "true");
servlet.service(req, resp);
assertFailureWithErrorMessage("java.lang.Exception: "
+ "parameter vclassId URI parameter expected ");
@ -175,7 +175,7 @@ public class JsonServletTest extends AbstractTestClass {
setLoggerLevel(JsonServlet.class, Level.FATAL);
setLoggerLevel(JsonObjectProducer.class, Level.FATAL);
String vclassId = "http://bogusVclass";
req.addParameter(GET_SOLR_INDIVIDUALS_BY_VCLASS, "true");
req.addParameter(GET_SEARCH_INDIVIDUALS_BY_VCLASS, "true");
req.addParameter(VCLASS_ID, vclassId);
servlet.service(req, resp);
@ -185,7 +185,8 @@ public class JsonServletTest extends AbstractTestClass {
/**
* TODO test successful responses. This will require figuring out how to
* stub SolrServer. It's an abstract class, so we just need to figure out
* stub SearchEngine. Since we are no longer dealing with an abstract class
* (like SolrServer), so we just need to figure out
* what sort of NamedList is required as a response to a request.
*/
@Test
@ -195,7 +196,7 @@ public class JsonServletTest extends AbstractTestClass {
setLoggerLevel(ModelAccess.class, Level.ERROR);
String vclassId = "http://myVclass";
vcDao.setVClass(vclassId, new VClass(vclassId));
req.addParameter(GET_SOLR_INDIVIDUALS_BY_VCLASS, "true");
req.addParameter(GET_SEARCH_INDIVIDUALS_BY_VCLASS, "true");
req.addParameter(VCLASS_ID, vclassId);
servlet.service(req, resp);

View file

@ -0,0 +1,80 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.searchengine;
import static org.junit.Assert.*;
import org.junit.Test;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
public class AutoCompleteWordsTest extends AbstractTestClass {
private static final String WORD_DELIMITER = "[, ]+";
private static final String FIELD_NAME_COMPLETE = "complete";
private static final String FIELD_NAME_PARTIAL = "partial";
@Test
public void nullSearchTerm() {
assertQueryString(null, "");
}
@Test
public void emptySearchTerm() {
assertQueryString("", "");
}
@Test
public void blankSearchTerm() {
assertQueryString(" ", "");
}
@Test
public void searchTermContainsOnlyCommas() {
assertQueryString(",,", "");
}
@Test
public void oneWord() {
assertQueryString("first", "partial:\"first\"");
}
@Test
public void twoWords() {
assertQueryString("first, second",
"complete:\"first\" AND partial:\"second\"");
}
@Test
public void threeWords() {
assertQueryString("first, second, third",
"complete:\"first\" AND complete:\"second\" AND partial:\"third\"");
}
@Test
public void oneWordAndComma() {
assertQueryString("first,", "complete:\"first\"");
}
@Test
public void oneWordAndCommaAndSpace() {
assertQueryString("first, ", "complete:\"first\"");
}
@Test
public void emptyCompleteWord() {
assertQueryString(", second", "partial:\"second\"");
}
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
private void assertQueryString(String searchTerm, String expected) {
AutoCompleteWords acw = new AutoCompleteWords(searchTerm,
WORD_DELIMITER);
String actual = acw.assembleQuery(FIELD_NAME_COMPLETE,
FIELD_NAME_PARTIAL);
assertEquals(expected, actual);
}
}

View file

@ -13,7 +13,7 @@ scripts list.-->
"individualsForClasses": "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter",
"sparqlQuery":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter",
"fixedHtml":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter",
"solrIndividuals":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter"
"solrIndividuals":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter"
}
};
</script>