VIVO-742 Many changes to remove "solr" from methods, variables, classes.
This commit is contained in:
parent
1bb5153857
commit
bf71c639fb
39 changed files with 347 additions and 277 deletions
|
@ -41,7 +41,7 @@ display:RequiredAction a owl:Class ;
|
||||||
a owl:Class ;
|
a owl:Class ;
|
||||||
rdfs:comment "Data getter for running a SPARQL query." .
|
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 ;
|
a owl:Class ;
|
||||||
rdfs:comment "A data getter for a Solr Class search, i.e. get individuals for VClass" .
|
rdfs:comment "A data getter for a Solr Class search, i.e. get individuals for VClass" .
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,12 @@ public class IndividualListRdfController extends VitroHttpServlet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
|
public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
|
||||||
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
|
|
||||||
// Make the query
|
// Make the query
|
||||||
String vclassUri = req.getParameter("vclass");
|
String vclassUri = req.getParameter("vclass");
|
||||||
String queryStr = VitroSearchTermNames.RDFTYPE + ":\"" + vclassUri + "\"";
|
String queryStr = VitroSearchTermNames.RDFTYPE + ":\"" + vclassUri + "\"";
|
||||||
SearchQuery query = ApplicationUtils.instance().getSearchEngine().createQuery(queryStr);
|
SearchQuery query = search.createQuery(queryStr);
|
||||||
query.setStart(0)
|
query.setStart(0)
|
||||||
.setRows(ENTITY_LIST_CONTROLLER_MAX_RESULTS)
|
.setRows(ENTITY_LIST_CONTROLLER_MAX_RESULTS)
|
||||||
.addFields(VitroSearchTermNames.URI);
|
.addFields(VitroSearchTermNames.URI);
|
||||||
|
@ -45,11 +46,10 @@ public class IndividualListRdfController extends VitroHttpServlet {
|
||||||
//.addSortField(VitroSearchTermNames.NAME_LOWERCASE_SINGLE_VALUED);
|
//.addSortField(VitroSearchTermNames.NAME_LOWERCASE_SINGLE_VALUED);
|
||||||
|
|
||||||
// Execute the query
|
// Execute the query
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
|
||||||
SearchResponse response = null;
|
SearchResponse response = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = solr.query(query);
|
response = search.query(query);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.error(t, t);
|
log.error(t, t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.accounts.admin.ajax;
|
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.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_LOWERCASE_SINGLE_VALUED;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_RAW;
|
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.NAME_UNSTEMMED;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.RDFTYPE;
|
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.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.io.IOException;
|
||||||
import java.util.Collection;
|
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;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery.Order;
|
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.modules.searchEngine.SearchResponse;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.AutoCompleteWords;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.AutoCompleteWords;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.FieldMap;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.FieldMap;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrResponseFilter;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchResponseFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of Profiles with last names that begin with this search term, and
|
* 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.
|
* if an error occurs, return an empty result.
|
||||||
*/
|
*/
|
||||||
class ProfileAutoCompleter extends AbstractAjaxResponder implements
|
class ProfileAutoCompleter extends AbstractAjaxResponder implements
|
||||||
SolrResponseFilter {
|
SearchResponseFilter {
|
||||||
private static final Log log = LogFactory
|
private static final Log log = LogFactory
|
||||||
.getLog(ProfileAutoCompleter.class);
|
.getLog(ProfileAutoCompleter.class);
|
||||||
|
|
||||||
|
@ -71,7 +70,7 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
|
||||||
.singleton("http://xmlns.com/foaf/0.1/Person");
|
.singleton("http://xmlns.com/foaf/0.1/Person");
|
||||||
|
|
||||||
private static final String WORD_DELIMITER = "[, ]+";
|
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");
|
.put(URI, "uri").put(NAME_RAW, "label");
|
||||||
|
|
||||||
private static final Syntax SYNTAX = Syntax.syntaxARQ;
|
private static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
@ -96,7 +95,7 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
|
||||||
this.externalAuthId = getStringParameter(PARAMETER_ETERNAL_AUTH_ID, "");
|
this.externalAuthId = getStringParameter(PARAMETER_ETERNAL_AUTH_ID, "");
|
||||||
|
|
||||||
this.term = getStringParameter(PARAMETER_SEARCH_TERM, "");
|
this.term = getStringParameter(PARAMETER_SEARCH_TERM, "");
|
||||||
this.searchWords = SolrQueryUtils.parseForAutoComplete(term,
|
this.searchWords = SearchQueryUtils.parseForAutoComplete(term,
|
||||||
WORD_DELIMITER);
|
WORD_DELIMITER);
|
||||||
|
|
||||||
// TODO This seems to expose the matching property and mechanism too
|
// TODO This seems to expose the matching property and mechanism too
|
||||||
|
@ -123,7 +122,7 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
|
||||||
SearchQuery query = buildSearchQuery();
|
SearchQuery query = buildSearchQuery();
|
||||||
SearchResponse queryResponse = executeSearchQuery(query);
|
SearchResponse queryResponse = executeSearchQuery(query);
|
||||||
|
|
||||||
List<Map<String, String>> maps = SolrQueryUtils
|
List<Map<String, String>> maps = SearchQueryUtils
|
||||||
.parseAndFilterResponse(queryResponse, RESPONSE_FIELDS,
|
.parseAndFilterResponse(queryResponse, RESPONSE_FIELDS,
|
||||||
this, 30);
|
this, 30);
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
|
||||||
SearchQuery q = ApplicationUtils.instance().getSearchEngine().createQuery();
|
SearchQuery q = ApplicationUtils.instance().getSearchEngine().createQuery();
|
||||||
q.addFields(NAME_RAW, URI);
|
q.addFields(NAME_RAW, URI);
|
||||||
q.addSortField(NAME_LOWERCASE_SINGLE_VALUED, Order.ASC);
|
q.addSortField(NAME_LOWERCASE_SINGLE_VALUED, Order.ASC);
|
||||||
q.addFilterQuery(SolrQueryUtils.assembleConjunctiveQuery(RDFTYPE,
|
q.addFilterQuery(SearchQueryUtils.assembleConjunctiveQuery(RDFTYPE,
|
||||||
profileTypes, OR));
|
profileTypes, OR));
|
||||||
q.setStart(0);
|
q.setStart(0);
|
||||||
q.setRows(10000);
|
q.setRows(10000);
|
||||||
|
@ -152,8 +151,8 @@ class ProfileAutoCompleter extends AbstractAjaxResponder implements
|
||||||
|
|
||||||
private SearchResponse executeSearchQuery(SearchQuery query)
|
private SearchResponse executeSearchQuery(SearchQuery query)
|
||||||
throws SearchEngineException {
|
throws SearchEngineException {
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
return solr.query(query);
|
return search.query(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ajax;
|
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.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_LOWERCASE_SINGLE_VALUED;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_RAW;
|
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.NAME_UNSTEMMED;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.RDFTYPE;
|
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.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.io.IOException;
|
||||||
import java.util.List;
|
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;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery.Order;
|
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.modules.searchEngine.SearchResponse;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.AutoCompleteWords;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.AutoCompleteWords;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.FieldMap;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.FieldMap;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the basic auto-complete info for the profile selection.
|
* 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 Log log = LogFactory.getLog(BasicProfilesGetter.class);
|
||||||
|
|
||||||
private static final String WORD_DELIMITER = "[, ]+";
|
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")
|
.fieldMap().put(URI, "uri").put(NAME_RAW, "label")
|
||||||
.put("bogus", "classLabel").put("bogus", "imageUrl");
|
.put("bogus", "classLabel").put("bogus", "imageUrl");
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
|
||||||
super(servlet, vreq, resp);
|
super(servlet, vreq, resp);
|
||||||
|
|
||||||
this.term = getStringParameter(PARAMETER_SEARCH_TERM, "");
|
this.term = getStringParameter(PARAMETER_SEARCH_TERM, "");
|
||||||
this.searchWords = SolrQueryUtils.parseForAutoComplete(term,
|
this.searchWords = SearchQueryUtils.parseForAutoComplete(term,
|
||||||
WORD_DELIMITER);
|
WORD_DELIMITER);
|
||||||
|
|
||||||
this.profileTypes = figureProfileTypes();
|
this.profileTypes = figureProfileTypes();
|
||||||
|
@ -69,7 +70,7 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
|
||||||
private List<String> figureProfileTypes() {
|
private List<String> figureProfileTypes() {
|
||||||
String typesString = ConfigurationProperties.getBean(vreq).getProperty(
|
String typesString = ConfigurationProperties.getBean(vreq).getProperty(
|
||||||
PROPERTY_PROFILE_TYPES, DEFAULT_PROFILE_TYPES);
|
PROPERTY_PROFILE_TYPES, DEFAULT_PROFILE_TYPES);
|
||||||
List<String> list = SolrQueryUtils.parseWords(typesString,
|
List<String> list = SearchQueryUtils.parseWords(typesString,
|
||||||
WORD_DELIMITER);
|
WORD_DELIMITER);
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
log.error("No types configured for profile pages in "
|
log.error("No types configured for profile pages in "
|
||||||
|
@ -86,11 +87,11 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
SearchQuery query = buildSearchQuery();
|
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);
|
.parseResponse(queryResponse, RESPONSE_FIELDS);
|
||||||
|
|
||||||
String response = assembleJsonResponse(parsed);
|
String response = assembleJsonResponse(parsed);
|
||||||
|
@ -106,7 +107,7 @@ public class BasicProfilesGetter extends AbstractAjaxResponder {
|
||||||
SearchQuery q = ApplicationUtils.instance().getSearchEngine().createQuery();
|
SearchQuery q = ApplicationUtils.instance().getSearchEngine().createQuery();
|
||||||
q.addFields(NAME_RAW, URI);
|
q.addFields(NAME_RAW, URI);
|
||||||
q.addSortField(NAME_LOWERCASE_SINGLE_VALUED, Order.ASC);
|
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.setStart(0);
|
||||||
q.setRows(30);
|
q.setRows(30);
|
||||||
q.setQuery(searchWords.assembleQuery(NAME_UNSTEMMED, AC_NAME_STEMMED));
|
q.setQuery(searchWords.assembleQuery(NAME_UNSTEMMED, AC_NAME_STEMMED));
|
||||||
|
|
|
@ -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.controller.individuallist.IndividualListResults;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
|
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;
|
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
|
//TODO: Remove and update reference within JsonServlet
|
||||||
public static String getAlphaParameter(VitroRequest request){
|
public static String getAlphaParameter(VitroRequest request){
|
||||||
return SolrQueryUtils.getAlphaParameter(request);
|
return SearchQueryUtils.getAlphaParameter(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Remove and update reference within JsonServlet
|
//TODO: Remove and update reference within JsonServlet
|
||||||
public static int getPageParameter(VitroRequest request) {
|
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)
|
public static IndividualListResults getResultsForVClass(String vclassURI, int page, String alpha, IndividualDao indDao)
|
||||||
throws SearchException{
|
throws SearchException{
|
||||||
try{
|
try{
|
||||||
List<String> classUris = Collections.singletonList(vclassURI);
|
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);
|
return getResultsForVClassQuery(results, page, INDIVIDUALS_PER_PAGE, alpha);
|
||||||
} catch (SearchEngineException e) {
|
} catch (SearchEngineException e) {
|
||||||
String msg = "An error occurred retrieving results for vclass query";
|
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) {
|
public static IndividualListResults getResultsForVClassIntersections(List<String> vclassURIs, int page, int pageSize, String alpha, IndividualDao indDao) {
|
||||||
try{
|
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);
|
return getResultsForVClassQuery(results, page, pageSize, alpha);
|
||||||
} catch(Throwable th) {
|
} catch(Throwable th) {
|
||||||
log.error("Error retrieving individuals corresponding to intersection multiple classes." + vclassURIs.toString(), 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) {
|
public static IndividualListResults getRandomResultsForVClass(String vclassURI, int page, int pageSize, IndividualDao indDao) {
|
||||||
try{
|
try{
|
||||||
List<String> classUris = Collections.singletonList(vclassURI);
|
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, "");
|
return getResultsForVClassQuery(results, page, pageSize, "");
|
||||||
} catch(Throwable th) {
|
} catch(Throwable th) {
|
||||||
log.error("An error occurred retrieving random results for vclass query", 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
|
//only within DataGetterUtils
|
||||||
public static long getIndividualCount(List<String> vclassUris, IndividualDao indDao) {
|
public static long getIndividualCount(List<String> vclassUris) {
|
||||||
return SolrQueryUtils.getIndividualCount(vclassUris, indDao);
|
return SearchQueryUtils.getIndividualCount(vclassUris);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IndividualListResults getResultsForVClassQuery(IndividualListQueryResults results, int page, int pageSize, String alpha) {
|
private static IndividualListResults getResultsForVClassQuery(IndividualListQueryResults results, int page, int pageSize, String alpha) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResultDocumen
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
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.
|
* Provides a convenience method to run the query and to find the Individuals.
|
||||||
*/
|
*/
|
||||||
|
@ -39,9 +39,8 @@ public class IndividualListQueryResults {
|
||||||
IndividualDao indDao)
|
IndividualDao indDao)
|
||||||
throws SearchEngineException {
|
throws SearchEngineException {
|
||||||
|
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
SearchResponse response = null;
|
SearchResponse response = search.query(query);
|
||||||
response = solr.query(query);
|
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
log.debug("response from search query was null");
|
log.debug("response from search query was null");
|
||||||
|
|
|
@ -271,12 +271,11 @@ public class JSONReconcileServlet extends VitroHttpServlet {
|
||||||
// begin search
|
// begin search
|
||||||
JSONArray resultJsonArr = new JSONArray();
|
JSONArray resultJsonArr = new JSONArray();
|
||||||
|
|
||||||
// Solr
|
|
||||||
SearchQuery query = getQuery(queryVal, searchType, limit, propertiesList);
|
SearchQuery query = getQuery(queryVal, searchType, limit, propertiesList);
|
||||||
SearchResponse queryResponse = null;
|
SearchResponse queryResponse = null;
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
queryResponse = solr.query(query);
|
queryResponse = search.query(query);
|
||||||
} else {
|
} else {
|
||||||
log.error("Query for a search was null");
|
log.error("Query for a search was null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* Does a Solr search for individuals, and uses the short view to render each of
|
||||||
* the results.
|
* the results.
|
||||||
*/
|
*/
|
||||||
public class GetRandomSolrIndividualsByVClass extends GetSolrIndividualsByVClass {
|
public class GetRandomSolrIndividualsByVClass extends GetSearchIndividualsByVClass {
|
||||||
private static final Log log = LogFactory
|
private static final Log log = LogFactory
|
||||||
.getLog(GetRandomSolrIndividualsByVClass.class);
|
.getLog(GetRandomSolrIndividualsByVClass.class);
|
||||||
|
|
||||||
|
|
|
@ -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
|
* Does a Solr search for individuals, and uses the short view to render each of
|
||||||
* the results.
|
* the results.
|
||||||
*/
|
*/
|
||||||
public class GetRenderedSolrIndividualsByVClass extends GetSolrIndividualsByVClasses {
|
public class GetRenderedSolrIndividualsByVClass extends GetSearchIndividualsByVClasses {
|
||||||
private static final Log log = LogFactory
|
private static final Log log = LogFactory
|
||||||
.getLog(GetRenderedSolrIndividualsByVClass.class);
|
.getLog(GetRenderedSolrIndividualsByVClass.class);
|
||||||
|
|
||||||
|
|
|
@ -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
|
private static final Log log = LogFactory
|
||||||
.getLog(GetSolrIndividualsByVClass.class);
|
.getLog(GetSearchIndividualsByVClass.class);
|
||||||
|
|
||||||
protected GetSolrIndividualsByVClass(VitroRequest vreq) {
|
protected GetSearchIndividualsByVClass(VitroRequest vreq) {
|
||||||
super(vreq);
|
super(vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,9 +39,9 @@ public class GetSolrIndividualsByVClass extends JsonObjectProducer {
|
||||||
|
|
||||||
vreq.setAttribute("displayType", vitroClassIdStr);
|
vreq.setAttribute("displayType", vitroClassIdStr);
|
||||||
if ( queryType != null && queryType.equals("random")){
|
if ( queryType != null && queryType.equals("random")){
|
||||||
return JsonServlet.getRandomSolrIndividualsByVClass(vclass.getURI(), vreq, ctx);
|
return JsonServlet.getRandomSearchIndividualsByVClass(vclass.getURI(), vreq);
|
||||||
} else {
|
} else {
|
||||||
return JsonServlet.getSolrIndividualsByVClass(vclass.getURI(), vreq, ctx);
|
return JsonServlet.getSearchIndividualsByVClass(vclass.getURI(), vreq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,11 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
* Accepts multiple vclasses and returns individuals which correspond to the
|
* Accepts multiple vclasses and returns individuals which correspond to the
|
||||||
* intersection of those classes (i.e. have all those types)
|
* 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
|
private static final Log log = LogFactory
|
||||||
.getLog(GetSolrIndividualsByVClasses.class);
|
.getLog(GetSearchIndividualsByVClasses.class);
|
||||||
|
|
||||||
public GetSolrIndividualsByVClasses(VitroRequest vreq) {
|
public GetSearchIndividualsByVClasses(VitroRequest vreq) {
|
||||||
super(vreq);
|
super(vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class GetSolrIndividualsByVClasses extends JsonObjectProducer {
|
||||||
throw new Exception("parameter vclassId URI parameter expected ");
|
throw new Exception("parameter vclassId URI parameter expected ");
|
||||||
}
|
}
|
||||||
List<String> vclassIds = Arrays.asList(vitroClassIdStr);
|
List<String> vclassIds = Arrays.asList(vitroClassIdStr);
|
||||||
return JsonServlet.getSolrIndividualsByVClasses(vclassIds, vreq, ctx);
|
return JsonServlet.getSearchIndividualsByVClasses(vclassIds, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,12 +3,9 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.json;
|
package edu.cornell.mannlib.vitro.webapp.controller.json;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.VitroHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
|
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.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.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils;
|
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 " +
|
throw new IllegalArgumentException("The call invoked deprecated classes " +
|
||||||
"and the parameter for this call appeared nowhere in the code base, " +
|
"and the parameter for this call appeared nowhere in the code base, " +
|
||||||
"so it was removed in May, 2012.");
|
"so it was removed in May, 2012.");
|
||||||
}else if( vreq.getParameter("getSolrIndividualsByVClass") != null ){
|
}else if( vreq.getParameter("getSearchIndividualsByVClass") != null ){
|
||||||
new GetSolrIndividualsByVClass(vreq).process(resp);
|
new GetSearchIndividualsByVClass(vreq).process(resp);
|
||||||
}else if( vreq.getParameter("getVClassesForVClassGroup") != null ){
|
}else if( vreq.getParameter("getVClassesForVClassGroup") != null ){
|
||||||
new GetVClassesForVClassGroup(vreq).process(resp);
|
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");
|
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 ){
|
} else if( vreq.getParameter("getDataForPage") != null ){
|
||||||
throw new IllegalArgumentException("The call invoked deprecated classes " +
|
throw new IllegalArgumentException("The call invoked deprecated classes " +
|
||||||
"and the parameter for this call appeared nowhere in the code base, " +
|
"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);
|
List<String> vclassURIs = Collections.singletonList(vclassURI);
|
||||||
VitroRequest vreq = new VitroRequest(req);
|
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
|
//last parameter indicates single vclass instead of multiple vclasses
|
||||||
return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, false);
|
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);
|
VitroRequest vreq = new VitroRequest(req);
|
||||||
log.debug("Retrieve solr results for vclasses" + vclassURIs.toString());
|
log.debug("Retrieve search results for vclasses" + vclassURIs.toString());
|
||||||
IndividualListResults vcResults = getSolrVClassIntersectionResults(vclassURIs, vreq, context);
|
IndividualListResults vcResults = getSearchVClassIntersectionResults(vclassURIs, vreq);
|
||||||
log.debug("Results returned from Solr for " + vclassURIs.toString() + " are of size " + vcResults.getTotalCount());
|
log.debug("Results returned from search engine for " + vclassURIs.toString() + " are of size " + vcResults.getTotalCount());
|
||||||
|
|
||||||
return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, true);
|
return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Including version for Solr query for Vclass Intersections
|
//Including version for search query for Vclass Intersections
|
||||||
private static IndividualListResults getSolrVClassIntersectionResults(List<String> vclassURIs, VitroRequest vreq, ServletContext context){
|
private static IndividualListResults getSearchVClassIntersectionResults(List<String> vclassURIs, VitroRequest vreq){
|
||||||
log.debug("Retrieving Solr intersection results for " + vclassURIs.toString());
|
log.debug("Retrieving search intersection results for " + vclassURIs.toString());
|
||||||
String alpha = IndividualListController.getAlphaParameter(vreq);
|
String alpha = IndividualListController.getAlphaParameter(vreq);
|
||||||
int page = IndividualListController.getPageParameter(vreq);
|
int page = IndividualListController.getPageParameter(vreq);
|
||||||
log.debug("Alpha and page parameters are " + alpha + " and " + page);
|
log.debug("Alpha and page parameters are " + alpha + " and " + page);
|
||||||
|
@ -128,17 +124,17 @@ public class JsonServlet extends VitroHttpServlet {
|
||||||
return value;
|
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);
|
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
|
//last parameter indicates single vclass instead of multiple vclasses
|
||||||
return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, false);
|
return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Including version for Random Solr query for Vclass Intersections
|
//Including version for Random Solr query for Vclass Intersections
|
||||||
private static IndividualListResults getRandomSolrVClassResults(String vclassURI, VitroRequest vreq, ServletContext context){
|
private static IndividualListResults getRandomSearchVClassResults(String vclassURI, VitroRequest vreq){
|
||||||
log.debug("Retrieving random Solr intersection results for " + vclassURI);
|
log.debug("Retrieving random search intersection results for " + vclassURI);
|
||||||
|
|
||||||
int page = IndividualListController.getPageParameter(vreq);
|
int page = IndividualListController.getPageParameter(vreq);
|
||||||
int pageSize = Integer.parseInt(vreq.getParameter("pageSize"));
|
int pageSize = Integer.parseInt(vreq.getParameter("pageSize"));
|
||||||
|
|
|
@ -56,15 +56,15 @@ import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||||
* The cache is updated asynchronously by the thread RebuildGroupCacheThread.
|
* The cache is updated asynchronously by the thread RebuildGroupCacheThread.
|
||||||
* A synchronous rebuild can be performed with VClassGroupCache.doSynchronousRebuild()
|
* 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
|
* It will not throw an exception but it will return a empty list of classes
|
||||||
* or class groups.
|
* or class groups.
|
||||||
*
|
*
|
||||||
* VClassGroupCache.doSynchronousRebuild() and the RebuildGroupCacheThread will try
|
* 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
|
* As of VIVO release 1.4, the counts come from the search index. If the
|
||||||
* solr index is not built or if there were problems building the index,
|
* search index is not built or if there were problems building the index,
|
||||||
* the class counts from VClassGroupCache will be incorrect.
|
* the class counts from VClassGroupCache will be incorrect.
|
||||||
*/
|
*/
|
||||||
public class VClassGroupCache implements IndexingEventListener {
|
public class VClassGroupCache implements IndexingEventListener {
|
||||||
|
@ -185,7 +185,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doSynchronousRebuild(){
|
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 attempts = 0;
|
||||||
int maxTries = 3;
|
int maxTries = 3;
|
||||||
|
@ -194,7 +194,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
||||||
while( attempts < maxTries ){
|
while( attempts < maxTries ){
|
||||||
try {
|
try {
|
||||||
attempts++;
|
attempts++;
|
||||||
rebuildCacheUsingSolr(this);
|
rebuildCacheUsingSearch(this);
|
||||||
break;
|
break;
|
||||||
} catch (SearchEngineException e) {
|
} catch (SearchEngineException e) {
|
||||||
exception = e;
|
exception = e;
|
||||||
|
@ -244,17 +244,15 @@ public class VClassGroupCache implements IndexingEventListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that rebuilds the cache. This will use a WebappDaoFactory,
|
* 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.
|
* 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();
|
long start = System.currentTimeMillis();
|
||||||
WebappDaoFactory wdFactory = ModelAccess.on(cache.context).getWebappDaoFactory();
|
WebappDaoFactory wdFactory = ModelAccess.on(cache.context).getWebappDaoFactory();
|
||||||
|
|
||||||
SearchEngine solrServer = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine searchEngine = ApplicationUtils.instance().getSearchEngine();
|
||||||
|
|
||||||
VitroFilters vFilters = VitroFilterUtils.getPublicFilter(cache.context);
|
VitroFilters vFilters = VitroFilterUtils.getPublicFilter(cache.context);
|
||||||
VClassGroupDao vcgDao = new WebappDaoFactoryFiltering(wdFactory, vFilters).getVClassGroupDao();
|
VClassGroupDao vcgDao = new WebappDaoFactoryFiltering(wdFactory, vFilters).getVClassGroupDao();
|
||||||
|
@ -263,7 +261,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
||||||
INCLUDE_UNINSTANTIATED, DONT_INCLUDE_INDIVIDUAL_COUNT);
|
INCLUDE_UNINSTANTIATED, DONT_INCLUDE_INDIVIDUAL_COUNT);
|
||||||
|
|
||||||
removeClassesHiddenFromSearch(groups, cache.context);
|
removeClassesHiddenFromSearch(groups, cache.context);
|
||||||
addCountsUsingSolr(groups, solrServer);
|
addCountsUsingSearch(groups, searchEngine);
|
||||||
cache.setCache(groups, classMapForGroups(groups));
|
cache.setCache(groups, classMapForGroups(groups));
|
||||||
|
|
||||||
log.debug("msec to build cache: " + (System.currentTimeMillis() - start));
|
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.
|
* Add the Individual count to classes in groups.
|
||||||
* @throws SearchEngineException
|
* @throws SearchEngineException
|
||||||
*/
|
*/
|
||||||
protected static void addCountsUsingSolr(List<VClassGroup> groups, SearchEngine solrServer)
|
protected static void addCountsUsingSearch(List<VClassGroup> groups, SearchEngine searchEngine)
|
||||||
throws SearchEngineException {
|
throws SearchEngineException {
|
||||||
if( groups == null || solrServer == null )
|
if( groups == null || searchEngine == null )
|
||||||
return;
|
return;
|
||||||
for( VClassGroup group : groups){
|
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 {
|
throws SearchEngineException {
|
||||||
if( group == null ) return;
|
if( group == null ) return;
|
||||||
|
|
||||||
String groupUri = group.getURI();
|
String groupUri = group.getURI();
|
||||||
String facetOnField = VitroSearchTermNames.RDFTYPE;
|
String facetOnField = VitroSearchTermNames.RDFTYPE;
|
||||||
|
|
||||||
SearchQuery query = ApplicationUtils.instance().getSearchEngine().createQuery().
|
SearchQuery query = searchEngine.createQuery().
|
||||||
setRows(0).
|
setRows(0).
|
||||||
setQuery(VitroSearchTermNames.CLASSGROUP_URI + ":" + groupUri ).
|
setQuery(VitroSearchTermNames.CLASSGROUP_URI + ":" + groupUri ).
|
||||||
setFaceting(true). //facet on type to get counts for classes in classgroup
|
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);
|
log.debug("query: " + query);
|
||||||
|
|
||||||
SearchResponse rsp = solrServer.query(query);
|
SearchResponse rsp = searchEngine.query(query);
|
||||||
|
|
||||||
//Get individual count
|
//Get individual count
|
||||||
long individualCount = rsp.getResults().getNumFound();
|
long individualCount = rsp.getResults().getNumFound();
|
||||||
|
@ -419,7 +417,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
||||||
setWorkLevel(WorkLevel.WORKING);
|
setWorkLevel(WorkLevel.WORKING);
|
||||||
rebuildRequested = false;
|
rebuildRequested = false;
|
||||||
try {
|
try {
|
||||||
rebuildCacheUsingSolr( cache );
|
rebuildCacheUsingSearch( cache );
|
||||||
log.debug("rebuildGroupCacheThread.run() -- rebuilt cache ");
|
log.debug("rebuildGroupCacheThread.run() -- rebuilt cache ");
|
||||||
failedAttempts = 0;
|
failedAttempts = 0;
|
||||||
delay = 100;
|
delay = 100;
|
||||||
|
@ -427,7 +425,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
||||||
failedAttempts++;
|
failedAttempts++;
|
||||||
if( failedAttempts >= maxFailedAttempts ){
|
if( failedAttempts >= maxFailedAttempts ){
|
||||||
log.error("Could not build VClassGroupCache. " +
|
log.error("Could not build VClassGroupCache. " +
|
||||||
"Could not connect with Solr after " +
|
"Could not connect with the search engine after " +
|
||||||
failedAttempts + " attempts.", e.getCause());
|
failedAttempts + " attempts.", e.getCause());
|
||||||
rebuildRequested = false;
|
rebuildRequested = false;
|
||||||
failedAttempts = 0;
|
failedAttempts = 0;
|
||||||
|
@ -435,7 +433,7 @@ public class VClassGroupCache implements IndexingEventListener {
|
||||||
}else{
|
}else{
|
||||||
rebuildRequested = true;
|
rebuildRequested = true;
|
||||||
delay = (int) (( Math.pow(2, failedAttempts) ) * 1000);
|
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.");
|
"again in " + delay + " msec.");
|
||||||
}
|
}
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
|
|
|
@ -26,16 +26,16 @@ import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.fields.FieldUtils;
|
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.
|
* Also it gets individuals that belong to the most specific type(s) specified.
|
||||||
*/
|
*/
|
||||||
public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions implements FieldOptions {
|
public class IndividualsViaSearchQueryOptions extends IndividualsViaVClassOptions implements FieldOptions {
|
||||||
private Log log = LogFactory.getLog(IndividualsViaSolrQueryOptions.class);
|
private Log log = LogFactory.getLog(IndividualsViaSearchQueryOptions.class);
|
||||||
|
|
||||||
private String subjectUri;
|
private String subjectUri;
|
||||||
private String predicateUri;
|
private String predicateUri;
|
||||||
private String objectUri;
|
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);
|
super(vclassURIs);
|
||||||
this.subjectUri = inputSubjectUri;
|
this.subjectUri = inputSubjectUri;
|
||||||
this.predicateUri = inputPredicateUri;
|
this.predicateUri = inputPredicateUri;
|
||||||
|
@ -46,10 +46,10 @@ public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions
|
||||||
protected Map<String,Individual> getIndividualsForClass(String vclassURI, WebappDaoFactory wDaoFact ){
|
protected Map<String,Individual> getIndividualsForClass(String vclassURI, WebappDaoFactory wDaoFact ){
|
||||||
Map<String, Individual> individualMap = new HashMap<String, Individual>();
|
Map<String, Individual> individualMap = new HashMap<String, Individual>();
|
||||||
try {
|
try {
|
||||||
SearchEngine solrServer = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine searchEngine = ApplicationUtils.instance().getSearchEngine();
|
||||||
|
|
||||||
//solr query for type count.
|
//search query for type count.
|
||||||
SearchQuery query = solrServer.createQuery();
|
SearchQuery query = searchEngine.createQuery();
|
||||||
if( VitroVocabulary.OWL_THING.equals( vclassURI )){
|
if( VitroVocabulary.OWL_THING.equals( vclassURI )){
|
||||||
query.setQuery( "*:*" );
|
query.setQuery( "*:*" );
|
||||||
}else{
|
}else{
|
||||||
|
@ -59,7 +59,7 @@ public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions
|
||||||
.setRows(1000);
|
.setRows(1000);
|
||||||
query.addFields(VitroSearchTermNames.URI); // fields to retrieve
|
query.addFields(VitroSearchTermNames.URI); // fields to retrieve
|
||||||
|
|
||||||
SearchResponse rsp = solrServer.query(query);
|
SearchResponse rsp = searchEngine.query(query);
|
||||||
SearchResultDocumentList docs = rsp.getResults();
|
SearchResultDocumentList docs = rsp.getResults();
|
||||||
long found = docs.getNumFound();
|
long found = docs.getNumFound();
|
||||||
if(found > 0) {
|
if(found > 0) {
|
||||||
|
@ -75,13 +75,13 @@ public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex) {
|
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) {
|
} catch(Exception ex) {
|
||||||
log.error("Error occurred in executing solr query ", ex);
|
log.error("Error occurred in executing search query ", ex);
|
||||||
}
|
}
|
||||||
return individualMap;
|
return individualMap;
|
||||||
}
|
}
|
|
@ -175,7 +175,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
||||||
|
|
||||||
private boolean tooManyRangeOptions(VitroRequest vreq, HttpSession session ) throws SearchEngineException {
|
private boolean tooManyRangeOptions(VitroRequest vreq, HttpSession session ) throws SearchEngineException {
|
||||||
List<VClass> rangeTypes = getRangeTypes(vreq);
|
List<VClass> rangeTypes = getRangeTypes(vreq);
|
||||||
SearchEngine solrServer = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine searchEngine = ApplicationUtils.instance().getSearchEngine();
|
||||||
|
|
||||||
List<String> types = new ArrayList<String>();
|
List<String> types = new ArrayList<String>();
|
||||||
for (VClass vclass : rangeTypes) {
|
for (VClass vclass : rangeTypes) {
|
||||||
|
@ -191,15 +191,15 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
||||||
|
|
||||||
long count = 0;
|
long count = 0;
|
||||||
for( String type:types){
|
for( String type:types){
|
||||||
//solr query for type count.
|
//search query for type count.
|
||||||
SearchQuery query = solrServer.createQuery();
|
SearchQuery query = searchEngine.createQuery();
|
||||||
if( VitroVocabulary.OWL_THING.equals( type )){
|
if( VitroVocabulary.OWL_THING.equals( type )){
|
||||||
query.setQuery( "*:*" );
|
query.setQuery( "*:*" );
|
||||||
}else{
|
}else{
|
||||||
query.setQuery( VitroSearchTermNames.RDFTYPE + ":" + type);
|
query.setQuery( VitroSearchTermNames.RDFTYPE + ":" + type);
|
||||||
}
|
}
|
||||||
query.setRows(0);
|
query.setRows(0);
|
||||||
SearchResponse rsp = solrServer.query(query);
|
SearchResponse rsp = searchEngine.query(query);
|
||||||
SearchResultDocumentList docs = rsp.getResults();
|
SearchResultDocumentList docs = rsp.getResults();
|
||||||
long found = docs.getNumFound();
|
long found = docs.getNumFound();
|
||||||
count = count + found;
|
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
|
//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));
|
formSpecificData.put("sparqlForAcFilter", getSparqlForAcFilter(vreq));
|
||||||
if(customErrorMessages != null && !customErrorMessages.isEmpty()) {
|
if(customErrorMessages != null && !customErrorMessages.isEmpty()) {
|
||||||
|
@ -562,18 +562,17 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object rangeIndividualsExist(HttpSession session, List<VClass> types) throws SearchEngineException {
|
private Object rangeIndividualsExist(List<VClass> types) throws SearchEngineException {
|
||||||
SearchEngine solrServer = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine searchEngine = ApplicationUtils.instance().getSearchEngine();
|
||||||
|
|
||||||
boolean rangeIndividualsFound = false;
|
boolean rangeIndividualsFound = false;
|
||||||
for( VClass type:types){
|
for( VClass type:types){
|
||||||
//solr for type count.
|
//search for type count.
|
||||||
SearchQuery query =ApplicationUtils.instance().getSearchEngine().createQuery();
|
SearchQuery query = searchEngine.createQuery();
|
||||||
|
|
||||||
query.setQuery( VitroSearchTermNames.RDFTYPE + ":" + type.getURI());
|
query.setQuery( VitroSearchTermNames.RDFTYPE + ":" + type.getURI());
|
||||||
query.setRows(0);
|
query.setRows(0);
|
||||||
|
|
||||||
SearchResponse rsp = solrServer.query(query);
|
SearchResponse rsp = searchEngine.query(query);
|
||||||
SearchResultDocumentList docs = rsp.getResults();
|
SearchResultDocumentList docs = rsp.getResults();
|
||||||
if( docs.getNumFound() > 0 ){
|
if( docs.getNumFound() > 0 ){
|
||||||
rangeIndividualsFound = true;
|
rangeIndividualsFound = true;
|
||||||
|
|
|
@ -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.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.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.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;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,11 @@ import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
//Returns the appropriate n3 based on data getter
|
//Returns the appropriate n3 based on data getter
|
||||||
public class ProcessSolrIndividualsDataGetterN3 extends ProcessDataGetterAbstract {
|
public class ProcessSearchIndividualsDataGetterN3 extends ProcessDataGetterAbstract {
|
||||||
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter";
|
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter";
|
||||||
private Log log = LogFactory.getLog(ProcessFixedHTMLN3.class);
|
private Log log = LogFactory.getLog(ProcessFixedHTMLN3.class);
|
||||||
|
|
||||||
public ProcessSolrIndividualsDataGetterN3(){
|
public ProcessSearchIndividualsDataGetterN3(){
|
||||||
|
|
||||||
}
|
}
|
||||||
//Pass in variable that represents the counter
|
//Pass in variable that represents the counter
|
|
@ -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.SearchEngineException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchResponse;
|
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.searchengine.FieldMap;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrResultsParser;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchResultsParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assist in cache management for individual profile pages.
|
* 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.
|
* 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
|
* record. The ETAG is a hash of the record's content and is updated each time
|
||||||
* the individual is re-indexed.
|
* 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
|
* generated, with a Cache-Control header that should prevent the cache from
|
||||||
* storing that response.
|
* storing that response.
|
||||||
*
|
*
|
||||||
* If the requesting user is not logged in, this filter will ask Solr for the
|
* If the requesting user is not logged in, this filter will ask the search
|
||||||
* ETAG on the requested individual. If it is the same as the ETAG supplied by
|
* engine for the ETAG on the requested individual. If it is the same as the
|
||||||
* the cache in the request, then the response is 304 Not Modified. Otherwise, a
|
* ETAG supplied by the cache in the request, then the response is 304 Not
|
||||||
* fresh response is generated.
|
* Modified. Otherwise, a fresh response is generated.
|
||||||
*
|
*
|
||||||
* An unconditional request may mean that there is no external cache, or that
|
* An unconditional request may mean that there is no external cache, or that
|
||||||
* the cache doesn't have a copy of this particular page.
|
* 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 PROPERTY_ENABLE_CACHING = "http.createCacheHeaders";
|
||||||
private static final String ETAG_FIELD = "etag";
|
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);
|
.put(ETAG_FIELD, ETAG_FIELD);
|
||||||
|
|
||||||
private ServletContext ctx;
|
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) {
|
private String findEtagForIndividual(String individualUri) {
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
SearchQuery query = solr.createQuery("URI:" + individualUri)
|
SearchQuery query = search.createQuery("URI:" + individualUri).addFields(
|
||||||
.addFields(ETAG_FIELD);
|
ETAG_FIELD);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SearchResponse response = solr.query(query);
|
SearchResponse response = search.query(query);
|
||||||
List<Map<String, String>> maps = new SolrResultsParser(response,
|
List<Map<String, String>> maps = new SearchResultsParser(response,
|
||||||
parserFieldMap).parse();
|
parserFieldMap).parse();
|
||||||
log.debug("Solr response for '" + query.getQuery() + "' was "
|
log.debug("Search response for '" + query.getQuery() + "' was "
|
||||||
+ maps);
|
+ maps);
|
||||||
|
|
||||||
if (maps.isEmpty()) {
|
if (maps.isEmpty()) {
|
||||||
|
@ -262,14 +262,14 @@ public class CachingResponseFilter implements Filter {
|
||||||
}
|
}
|
||||||
} catch (SearchEngineException e) {
|
} catch (SearchEngineException e) {
|
||||||
log.warn(
|
log.warn(
|
||||||
"Solr query '" + query.getQuery() + "' threw an exception",
|
"Search query '" + query.getQuery() + "' threw an exception",
|
||||||
e);
|
e);
|
||||||
return null;
|
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
|
* different versions for different languages. Add the Locales from the
|
||||||
* request to make it unique.
|
* request to make it unique.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -74,8 +74,8 @@ public class AutocompleteController extends VitroAjaxController {
|
||||||
}
|
}
|
||||||
log.debug("query for '" + qtxt +"' is " + query.toString());
|
log.debug("query for '" + qtxt +"' is " + query.toString());
|
||||||
|
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
SearchResponse queryResponse = solr.query(query);
|
SearchResponse queryResponse = search.query(query);
|
||||||
|
|
||||||
if ( queryResponse == null) {
|
if ( queryResponse == null) {
|
||||||
log.error("Query response for a search was null");
|
log.error("Query response for a search was null");
|
||||||
|
@ -254,7 +254,7 @@ public class AutocompleteController extends VitroAjaxController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String escapeWhitespaceInQueryString(String queryStr) {
|
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+", "\\\\ ");
|
return queryStr.replaceAll("\\s+", "\\\\ ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,10 +55,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.searchresult.Individu
|
||||||
import edu.ucsf.vitro.opensocial.OpenSocialManager;
|
import edu.ucsf.vitro.opensocial.OpenSocialManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paged search controller that uses Solr
|
* Paged search controller that uses the search engine
|
||||||
*
|
|
||||||
* @author bdc34, rjy7
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PagedSearchController extends FreemarkerHttpServlet {
|
public class PagedSearchController extends FreemarkerHttpServlet {
|
||||||
|
@ -170,14 +167,14 @@ public class PagedSearchController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchQuery query = getQuery(queryText, hitsPerPage, startIndex, vreq);
|
SearchQuery query = getQuery(queryText, hitsPerPage, startIndex, vreq);
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
SearchResponse response = null;
|
SearchResponse response = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = solr.query(query);
|
response = search.query(query);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
String msg = makeBadSearchMessage(queryText, ex.getMessage(), vreq);
|
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);
|
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) {
|
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.
|
// processing to a wildcard search term.
|
||||||
SearchQuery query = ApplicationUtils.instance().getSearchEngine().createQuery(queryText);
|
SearchQuery query = ApplicationUtils.instance().getSearchEngine().createQuery(queryText);
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,14 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
|
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface;
|
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;
|
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||||
|
|
||||||
class IndexWorkerThread extends VitroBackgroundThread{
|
class IndexWorkerThread extends VitroBackgroundThread{
|
||||||
private static final Log log = LogFactory.getLog(IndexWorkerThread.class);
|
private static final Log log = LogFactory.getLog(IndexWorkerThread.class);
|
||||||
|
|
||||||
protected final int threadNum;
|
protected final int threadNum;
|
||||||
protected IndividualToSolrDocument individualToSolrDoc;
|
protected IndividualToSearchDocument individualToSolrDoc;
|
||||||
protected final IndexerIface indexer;
|
protected final IndexerIface indexer;
|
||||||
protected final Iterator<Individual> individualsToIndex;
|
protected final Iterator<Individual> individualsToIndex;
|
||||||
protected boolean stopRequested = false;
|
protected boolean stopRequested = false;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
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.modules.searchEngine.SearchResultDocumentList;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
|
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface;
|
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 {
|
public class SearchIndexer implements IndexerIface {
|
||||||
private final static Log log = LogFactory.getLog(SolrIndexer.class);
|
private final static Log log = LogFactory.getLog(SearchIndexer.class);
|
||||||
|
|
||||||
protected SearchEngine server;
|
protected SearchEngine server;
|
||||||
protected boolean indexing;
|
protected boolean indexing;
|
||||||
protected HashSet<String> urisIndexed;
|
protected HashSet<String> urisIndexed;
|
||||||
protected IndividualToSolrDocument individualToSolrDoc;
|
protected IndividualToSearchDocument individualToSearchDoc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System is shutting down if true.
|
* 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
|
* 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.
|
* reindexStart can be removed.
|
||||||
*/
|
*/
|
||||||
protected long reindexStart = 0L;
|
protected long reindexStart = 0L;
|
||||||
|
@ -49,15 +48,15 @@ public class SolrIndexer implements IndexerIface {
|
||||||
*/
|
*/
|
||||||
protected boolean doingFullIndexRebuild = false;
|
protected boolean doingFullIndexRebuild = false;
|
||||||
|
|
||||||
public SolrIndexer( SearchEngine server, IndividualToSolrDocument indToDoc){
|
public SearchIndexer( SearchEngine server, IndividualToSearchDocument indToDoc){
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.individualToSolrDoc = indToDoc;
|
this.individualToSearchDoc = indToDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void index(Individual ind) throws IndexingException {
|
public void index(Individual ind) throws IndexingException {
|
||||||
if( ! indexing )
|
if( ! indexing )
|
||||||
throw new IndexingException("SolrIndexer: must call " +
|
throw new IndexingException("SearchIndexer: must call " +
|
||||||
"startIndexing() before index().");
|
"startIndexing() before index().");
|
||||||
|
|
||||||
if( ind == null ) {
|
if( ind == null ) {
|
||||||
|
@ -70,20 +69,20 @@ public class SolrIndexer implements IndexerIface {
|
||||||
log.debug("already indexed " + ind.getURI() );
|
log.debug("already indexed " + ind.getURI() );
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
SearchInputDocument solrDoc = null;
|
SearchInputDocument doc = null;
|
||||||
synchronized(this){
|
synchronized(this){
|
||||||
urisIndexed.add(ind.getURI());
|
urisIndexed.add(ind.getURI());
|
||||||
}
|
}
|
||||||
log.debug("indexing " + ind.getURI());
|
log.debug("indexing " + ind.getURI());
|
||||||
solrDoc = individualToSolrDoc.translate(ind);
|
doc = individualToSearchDoc.translate(ind);
|
||||||
|
|
||||||
if( solrDoc != null){
|
if( doc != null){
|
||||||
if( log.isDebugEnabled()){
|
if( log.isDebugEnabled()){
|
||||||
log.info("boost for " + ind.getName() + " is " + solrDoc.getDocumentBoost());
|
log.info("boost for " + ind.getName() + " is " + doc.getDocumentBoost());
|
||||||
log.debug( solrDoc.toString() );
|
log.debug( doc.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
server.add( solrDoc );
|
server.add( doc );
|
||||||
log.debug("Added docs to server.");
|
log.debug("Added docs to server.");
|
||||||
}else{
|
}else{
|
||||||
log.debug("removing from index " + ind.getURI());
|
log.debug("removing from index " + ind.getURI());
|
||||||
|
@ -110,7 +109,7 @@ public class SolrIndexer implements IndexerIface {
|
||||||
public void removeFromIndex(String uri) throws IndexingException {
|
public void removeFromIndex(String uri) throws IndexingException {
|
||||||
if( uri != null ){
|
if( uri != null ){
|
||||||
try {
|
try {
|
||||||
server.deleteById(individualToSolrDoc.getIdForUri(uri));
|
server.deleteById(individualToSearchDoc.getIdForUri(uri));
|
||||||
log.debug("deleted " + " " + uri);
|
log.debug("deleted " + " " + uri);
|
||||||
} catch (SearchEngineException e) {
|
} catch (SearchEngineException e) {
|
||||||
log.error( "could not delete individual " + uri, e);
|
log.error( "could not delete individual " + uri, e);
|
||||||
|
@ -121,7 +120,7 @@ public class SolrIndexer implements IndexerIface {
|
||||||
@Override
|
@Override
|
||||||
public synchronized void startIndexing() throws IndexingException {
|
public synchronized void startIndexing() throws IndexingException {
|
||||||
if( indexing)
|
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.
|
while( indexing && ! shutdownRequested ){ //wait for indexing to end.
|
||||||
try{ wait( 250 ); }
|
try{ wait( 250 ); }
|
||||||
catch(InterruptedException ex){}
|
catch(InterruptedException ex){}
|
||||||
|
@ -137,7 +136,7 @@ public class SolrIndexer implements IndexerIface {
|
||||||
public void abortIndexingAndCleanUp() {
|
public void abortIndexingAndCleanUp() {
|
||||||
shutdownRequested = true;
|
shutdownRequested = true;
|
||||||
try{
|
try{
|
||||||
individualToSolrDoc.shutdown();
|
individualToSearchDoc.shutdown();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
if( log != null)
|
if( log != null)
|
||||||
log.debug(e,e);
|
log.debug(e,e);
|
||||||
|
@ -159,8 +158,8 @@ public class SolrIndexer implements IndexerIface {
|
||||||
server.commit();
|
server.commit();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if( ! shutdownRequested ){
|
if( ! shutdownRequested ){
|
||||||
log.debug("could not commit to solr server, " +
|
log.debug("could not commit to the search engine, " +
|
||||||
"this should not be a problem since solr will do autocommit");
|
"this should not be a problem since the search engine will do autocommit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
indexing = false;
|
indexing = false;
|
||||||
|
@ -213,7 +212,7 @@ public class SolrIndexer implements IndexerIface {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (SearchEngineException e) {
|
} 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;
|
return false;
|
||||||
}
|
}
|
|
@ -37,7 +37,7 @@ public class ContextNodeFields implements DocumentModifier{
|
||||||
protected RDFServiceFactory rdfServiceFactory;
|
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.
|
* a list of the SPARQL queries to run.
|
||||||
*/
|
*/
|
||||||
protected ContextNodeFields(List<String> queries, RDFServiceFactory rdfServiceFactory){
|
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
|
* 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
|
* @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){
|
protected StringBuffer executeQueryForValues( Individual individual, Collection<String> queries){
|
||||||
/* execute all the queries on the list and concat the values to add to all text */
|
/* execute all the queries on the list and concat the values to add to all text */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -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.IndexingException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
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();
|
public static VitroSearchTermNames term = new VitroSearchTermNames();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class IndividualToSolrDocument {
|
||||||
|
|
||||||
protected List<SearchIndexExcluder> excludes;
|
protected List<SearchIndexExcluder> excludes;
|
||||||
|
|
||||||
public IndividualToSolrDocument(List<SearchIndexExcluder> excludes, List<DocumentModifier> docModifiers){
|
public IndividualToSearchDocument(List<SearchIndexExcluder> excludes, List<DocumentModifier> docModifiers){
|
||||||
this.excludes = excludes;
|
this.excludes = excludes;
|
||||||
this.documentModifiers = docModifiers;
|
this.documentModifiers = docModifiers;
|
||||||
}
|
}
|
||||||
|
@ -302,12 +302,12 @@ public class IndividualToSolrDocument {
|
||||||
doc.addField(term.NAME_RAW, value);
|
doc.addField(term.NAME_RAW, value);
|
||||||
doc.addField(term.NAME_LOWERCASE_SINGLE_VALUED,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
|
// NAME_LOWERCASE, NAME_UNSTEMMED, NAME_STEMMED, NAME_PHONETIC, AC_NAME_UNTOKENIZED, AC_NAME_STEMMED
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getIndexId(Object obj) {
|
public Object getIndexId(Object obj) {
|
||||||
throw new Error("IndiviudalToSolrDocument.getIndexId() is unimplemented");
|
throw new Error("IndiviudalToSearchDocument.getIndexId() is unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdForUri(String uri){
|
public String getIdForUri(String uri){
|
|
@ -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.AdditionalUriFinders;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
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.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.DocumentModifier;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnNamespace;
|
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.ExcludeBasedOnType;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnTypeNamespace;
|
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.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.NameBoost;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.NameFields;
|
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.NameFields;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.SearchIndexExcluder;
|
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
|
List<SearchIndexExcluder> searchIndexExcludesFromContext = (List<SearchIndexExcluder>) context
|
||||||
.getAttribute("SearchIndexExcludes");
|
.getAttribute("SearchIndexExcludes");
|
||||||
|
|
||||||
IndividualToSolrDocument indToSolrDoc = setupTransltion(
|
IndividualToSearchDocument indToSolrDoc = setupTransltion(
|
||||||
jenaOntModel, displayModel,
|
jenaOntModel, displayModel,
|
||||||
RDFServiceUtils.getRDFServiceFactory(context),
|
RDFServiceUtils.getRDFServiceFactory(context),
|
||||||
modifiersFromContext, searchIndexExcludesFromContext);
|
modifiersFromContext, searchIndexExcludesFromContext);
|
||||||
|
|
||||||
/* setup solr indexer */
|
/* 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
|
// 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
|
// 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,
|
OntModel jenaOntModel, Model displayModel,
|
||||||
RDFServiceFactory rdfServiceFactory,
|
RDFServiceFactory rdfServiceFactory,
|
||||||
List<DocumentModifier> modifiersFromContext,
|
List<DocumentModifier> modifiersFromContext,
|
||||||
|
@ -187,6 +187,6 @@ public class SearchIndexerSetup implements ServletContextListener {
|
||||||
excludes.add(new ExcludeNonFlagVitro());
|
excludes.add(new ExcludeNonFlagVitro());
|
||||||
excludes.add(new SyncingExcludeBasedOnType(displayModel));
|
excludes.add(new SyncingExcludeBasedOnType(displayModel));
|
||||||
|
|
||||||
return new IndividualToSolrDocument(excludes, modifiers);
|
return new IndividualToSearchDocument(excludes, modifiers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class BrowseDataGetter extends DataGetterBase implements DataGetter {
|
||||||
|
|
||||||
//Get data servuice
|
//Get data servuice
|
||||||
public String getDataServiceUrl() {
|
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 {
|
private Map<String, Object> doClassAlphaDisplay( Map params, VitroRequest request, ServletContext context) throws Exception {
|
||||||
Map<String,Object> body = new HashMap<String,Object>();
|
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);
|
VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(classUri);
|
||||||
map.put("class", new VClassTemplateModel(vclass));
|
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("totalCount", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("totalCount") ));
|
||||||
map.put("alpha", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("alpha") ));
|
map.put("alpha", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("alpha") ));
|
||||||
map.put("individuals", JsonToFmModel.convertJSONArrayToList( (JSONArray) vclassRes.get("individuals") ));
|
map.put("individuals", JsonToFmModel.convertJSONArrayToList( (JSONArray) vclassRes.get("individuals") ));
|
||||||
|
|
|
@ -267,10 +267,10 @@ public class DataGetterUtils {
|
||||||
* For page data getter conversions
|
* 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) {
|
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
|
//Return data getter type to be employed in display model
|
||||||
|
|
|
@ -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.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResults;
|
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResults;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
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;
|
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;
|
String dataGetterURI;
|
||||||
List<String> vclassUris = null;
|
List<String> vclassUris = null;
|
||||||
String saveToVar;
|
String saveToVar;
|
||||||
|
@ -45,14 +45,14 @@ public class SolrIndividualsDataGetter extends DataGetterBase implements DataGet
|
||||||
ServletContext context;
|
ServletContext context;
|
||||||
|
|
||||||
|
|
||||||
final static Log log = LogFactory.getLog(SolrIndividualsDataGetter.class);
|
final static Log log = LogFactory.getLog(SearchIndividualsDataGetter.class);
|
||||||
//default template
|
//default template
|
||||||
private final static String defaultTemplate = "menupage--defaultSolrIndividuals.ftl";
|
private final static String defaultTemplate = "menupage--defaultSolrIndividuals.ftl";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with display model and data getter URI that will be called by reflection.
|
* 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);
|
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) {
|
private void populateSolrQueryResults(VClass vclass, Map<String, Object> body) {
|
||||||
try {
|
try {
|
||||||
String alpha = SolrQueryUtils.getAlphaParameter(vreq);
|
String alpha = SearchQueryUtils.getAlphaParameter(vreq);
|
||||||
int page = SolrQueryUtils.getPageParameter(vreq);
|
int page = SearchQueryUtils.getPageParameter(vreq);
|
||||||
IndividualListResults vcResults = IndividualListController.getResultsForVClass(
|
IndividualListResults vcResults = IndividualListController.getResultsForVClass(
|
||||||
vclass.getURI(),
|
vclass.getURI(),
|
||||||
page,
|
page,
|
|
@ -1,6 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $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.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -27,15 +27,16 @@ public class AutoCompleteWords {
|
||||||
private final String partialWord;
|
private final String partialWord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package-access. Use SolrQueryUtils.parseForAutoComplete() to create an
|
* Package-access. Use SearchQueryUtils.parseForAutoComplete() to create an
|
||||||
* instance.
|
* instance.
|
||||||
*/
|
*/
|
||||||
AutoCompleteWords(String searchTerm, String delimiterPattern) {
|
AutoCompleteWords(String searchTerm, String delimiterPattern) {
|
||||||
this.searchTerm = searchTerm;
|
this.searchTerm = (searchTerm == null) ? "" : searchTerm;
|
||||||
this.delimiterPattern = delimiterPattern;
|
this.delimiterPattern = delimiterPattern;
|
||||||
|
|
||||||
List<String> termWords = figureTermWords();
|
List<String> termWords = figureTermWords();
|
||||||
if (termWords.isEmpty() || this.searchTerm.endsWith(" ")) {
|
if (termWords.isEmpty()
|
||||||
|
|| this.searchTerm.matches(".*" + delimiterPattern)) {
|
||||||
this.completeWords = termWords;
|
this.completeWords = termWords;
|
||||||
this.partialWord = null;
|
this.partialWord = null;
|
||||||
} else {
|
} else {
|
|
@ -1,17 +1,17 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $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.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A builder object that can assemble a map of Solr field names to JSON field
|
* A builder object that can assemble a map of search result field names to JSON
|
||||||
* names.
|
* field names.
|
||||||
*
|
*
|
||||||
* Use like this:
|
* 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 {
|
public class FieldMap {
|
||||||
|
@ -20,14 +20,15 @@ public class FieldMap {
|
||||||
/**
|
/**
|
||||||
* Add a row to the map
|
* Add a row to the map
|
||||||
*/
|
*/
|
||||||
public FieldMap put(String solrFieldName, String jsonFieldName) {
|
public FieldMap put(String searchResultFieldName, String jsonFieldName) {
|
||||||
if (solrFieldName == null) {
|
if (searchResultFieldName == null) {
|
||||||
throw new NullPointerException("solrFieldName may not be null.");
|
throw new NullPointerException(
|
||||||
|
"searchResultFieldName may not be null.");
|
||||||
}
|
}
|
||||||
if (jsonFieldName == null) {
|
if (jsonFieldName == null) {
|
||||||
throw new NullPointerException("jsonFieldName may not be null.");
|
throw new NullPointerException("jsonFieldName may not be null.");
|
||||||
}
|
}
|
||||||
m.put(solrFieldName, jsonFieldName);
|
m.put(searchResultFieldName, jsonFieldName);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $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.ArrayList;
|
||||||
import java.util.Collection;
|
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;
|
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.
|
* results.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SolrQueryUtils {
|
public class SearchQueryUtils {
|
||||||
private static final Log log = LogFactory.getLog(SolrQueryUtils.class.getName());
|
private static final Log log = LogFactory.getLog(SearchQueryUtils.class.getName());
|
||||||
|
|
||||||
public enum Conjunction {
|
public enum Conjunction {
|
||||||
AND, OR;
|
AND, OR;
|
||||||
|
@ -48,8 +48,8 @@ public class SolrQueryUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a builder object that can assemble a map of Solr field names to
|
* Create a builder object that can assemble a map of search result field
|
||||||
* JSON field names.
|
* names to JSON field names.
|
||||||
*/
|
*/
|
||||||
public static FieldMap fieldMap() {
|
public static FieldMap fieldMap() {
|
||||||
return new FieldMap();
|
return new FieldMap();
|
||||||
|
@ -58,25 +58,25 @@ public class SolrQueryUtils {
|
||||||
/**
|
/**
|
||||||
* Parse a response into a list of maps, one map for each document.
|
* 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 search result field names in the document are replaced by json field
|
||||||
* the result, according to the fieldMap.
|
* names in the result, according to the fieldMap.
|
||||||
*/
|
*/
|
||||||
public static List<Map<String, String>> parseResponse(
|
public static List<Map<String, String>> parseResponse(
|
||||||
SearchResponse queryResponse, FieldMap fieldMap) {
|
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
|
* 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.
|
* 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 search result field names in the document are replaced by json field
|
||||||
* the result, according to the fieldMap.
|
* names in the result, according to the fieldMap.
|
||||||
*/
|
*/
|
||||||
public static List<Map<String, String>> parseAndFilterResponse(
|
public static List<Map<String, String>> parseAndFilterResponse(
|
||||||
SearchResponse queryResponse, FieldMap fieldMap,
|
SearchResponse queryResponse, FieldMap fieldMap,
|
||||||
SolrResponseFilter filter, int maxNumberOfResults) {
|
SearchResponseFilter filter, int maxNumberOfResults) {
|
||||||
return new SolrResultsParser(queryResponse, fieldMap)
|
return new SearchResultsParser(queryResponse, fieldMap)
|
||||||
.parseAndFilterResponse(filter, maxNumberOfResults);
|
.parseAndFilterResponse(filter, maxNumberOfResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,8 +107,7 @@ public class SolrQueryUtils {
|
||||||
for (String word : words) {
|
for (String word : words) {
|
||||||
terms.add(buildTerm(fieldName, word));
|
terms.add(buildTerm(fieldName, word));
|
||||||
}
|
}
|
||||||
String q = StringUtils.join(terms, c.joiner());
|
return StringUtils.join(terms, c.joiner());
|
||||||
return q;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String buildTerm(String fieldName, String word) {
|
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){
|
public static String getAlphaParameter(VitroRequest request){
|
||||||
|
@ -138,13 +138,13 @@ public class SolrQueryUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get count of individuals without actually getting the results
|
//Get count of individuals without actually getting the results
|
||||||
public static long getIndividualCount(List<String> vclassUris, IndividualDao indDao) {
|
public static long getIndividualCount(List<String> vclassUris) {
|
||||||
SearchEngine solr = ApplicationUtils.instance().getSearchEngine();
|
SearchEngine search = ApplicationUtils.instance().getSearchEngine();
|
||||||
SearchQuery query = solr.createQuery(makeMultiClassQuery(vclassUris));
|
SearchQuery query = search.createQuery(makeMultiClassQuery(vclassUris));
|
||||||
query.setRows(0);
|
query.setRows(0);
|
||||||
try {
|
try {
|
||||||
SearchResponse response = null;
|
SearchResponse response = null;
|
||||||
response = solr.query(query);
|
response = search.query(query);
|
||||||
return response.getResults().getNumFound();
|
return response.getResults().getNumFound();
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("An error occured in retrieving individual count", ex);
|
log.error("An error occured in retrieving individual count", ex);
|
||||||
|
@ -181,7 +181,7 @@ public class SolrQueryUtils {
|
||||||
return query;
|
return query;
|
||||||
|
|
||||||
} catch (Exception ex){
|
} catch (Exception ex){
|
||||||
log.error("Could not make Solr query",ex);
|
log.error("Could not make the search query",ex);
|
||||||
return searchEngine.createQuery();
|
return searchEngine.createQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ public class SolrQueryUtils {
|
||||||
return query;
|
return query;
|
||||||
|
|
||||||
} catch (Exception ex){
|
} catch (Exception ex){
|
||||||
log.error("Could not make the Solr query",ex);
|
log.error("Could not make the search query",ex);
|
||||||
return searchEngine.createQuery();
|
return searchEngine.createQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ public class SolrQueryUtils {
|
||||||
}
|
}
|
||||||
return StringUtils.join(queryTypes, " AND ");
|
return StringUtils.join(queryTypes, " AND ");
|
||||||
} catch (Exception ex){
|
} catch (Exception ex){
|
||||||
log.error("Could not make Solr query",ex);
|
log.error("Could not make the search query",ex);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,9 +224,9 @@ public class SolrQueryUtils {
|
||||||
public static IndividualListQueryResults buildAndExecuteVClassQuery(
|
public static IndividualListQueryResults buildAndExecuteVClassQuery(
|
||||||
List<String> vclassURIs, String alpha, int page, int pageSize, IndividualDao indDao)
|
List<String> vclassURIs, String alpha, int page, int pageSize, IndividualDao indDao)
|
||||||
throws SearchEngineException {
|
throws SearchEngineException {
|
||||||
SearchQuery query = SolrQueryUtils.getQuery(vclassURIs, alpha, page, pageSize);
|
SearchQuery query = SearchQueryUtils.getQuery(vclassURIs, alpha, page, pageSize);
|
||||||
IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao);
|
IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao);
|
||||||
log.debug("Executed solr query for " + vclassURIs);
|
log.debug("Executed search query for " + vclassURIs);
|
||||||
if (results.getIndividuals().isEmpty()) {
|
if (results.getIndividuals().isEmpty()) {
|
||||||
log.debug("entities list is null for vclass " + vclassURIs);
|
log.debug("entities list is null for vclass " + vclassURIs);
|
||||||
}
|
}
|
||||||
|
@ -236,9 +236,9 @@ public class SolrQueryUtils {
|
||||||
public static IndividualListQueryResults buildAndExecuteRandomVClassQuery(
|
public static IndividualListQueryResults buildAndExecuteRandomVClassQuery(
|
||||||
List<String> vclassURIs, int page, int pageSize, IndividualDao indDao)
|
List<String> vclassURIs, int page, int pageSize, IndividualDao indDao)
|
||||||
throws SearchEngineException {
|
throws SearchEngineException {
|
||||||
SearchQuery query = SolrQueryUtils.getRandomQuery(vclassURIs, page, pageSize);
|
SearchQuery query = SearchQueryUtils.getRandomQuery(vclassURIs, page, pageSize);
|
||||||
IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao);
|
IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao);
|
||||||
log.debug("Executed solr query for " + vclassURIs);
|
log.debug("Executed search query for " + vclassURIs);
|
||||||
if (results.getIndividuals().isEmpty()) {
|
if (results.getIndividuals().isEmpty()) {
|
||||||
log.debug("entities list is null for vclass " + vclassURIs);
|
log.debug("entities list is null for vclass " + vclassURIs);
|
||||||
}
|
}
|
|
@ -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);
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $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.ArrayList;
|
||||||
import java.util.HashMap;
|
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;
|
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
|
* The search response field names in the document are replaced by json field
|
||||||
* parsed results, according to the fieldMap.
|
* names in the parsed results, according to the fieldMap.
|
||||||
*/
|
*/
|
||||||
public class SolrResultsParser {
|
public class SearchResultsParser {
|
||||||
private static final Log log = LogFactory.getLog(SolrResultsParser.class);
|
private static final Log log = LogFactory.getLog(SearchResultsParser.class);
|
||||||
|
|
||||||
private final SearchResponse queryResponse;
|
private final SearchResponse queryResponse;
|
||||||
private final Map<String, String> fieldNameMapping;
|
private final Map<String, String> fieldNameMapping;
|
||||||
|
|
||||||
public SolrResultsParser(SearchResponse queryResponse, FieldMap fieldMap) {
|
public SearchResultsParser(SearchResponse queryResponse, FieldMap fieldMap) {
|
||||||
this.queryResponse = queryResponse;
|
this.queryResponse = queryResponse;
|
||||||
this.fieldNameMapping = fieldMap.map();
|
this.fieldNameMapping = fieldMap.map();
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class SolrResultsParser {
|
||||||
* have parsed the entire response).
|
* have parsed the entire response).
|
||||||
*/
|
*/
|
||||||
public List<Map<String, String>> parseAndFilterResponse(
|
public List<Map<String, String>> parseAndFilterResponse(
|
||||||
SolrResponseFilter filter, int maxNumberOfResults) {
|
SearchResponseFilter filter, int maxNumberOfResults) {
|
||||||
List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
|
||||||
|
|
||||||
if (queryResponse == null) {
|
if (queryResponse == null) {
|
||||||
|
@ -95,10 +95,10 @@ public class SolrResultsParser {
|
||||||
*/
|
*/
|
||||||
private Map<String, String> parseSingleDocument(SearchResultDocument doc) {
|
private Map<String, String> parseSingleDocument(SearchResultDocument doc) {
|
||||||
Map<String, String> result = new HashMap<String, String>();
|
Map<String, String> result = new HashMap<String, String>();
|
||||||
for (String solrFieldName : fieldNameMapping.keySet()) {
|
for (String searchResultFieldName : fieldNameMapping.keySet()) {
|
||||||
String jsonFieldName = fieldNameMapping.get(solrFieldName);
|
String jsonFieldName = fieldNameMapping.get(searchResultFieldName);
|
||||||
|
result.put(jsonFieldName,
|
||||||
result.put(jsonFieldName, parseSingleValue(doc, solrFieldName));
|
parseSingleValue(doc, searchResultFieldName));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
|
@ -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);
|
|
||||||
}
|
|
|
@ -83,7 +83,7 @@ public class BrowseWidget extends Widget {
|
||||||
VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(classUri);
|
VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(classUri);
|
||||||
map.put("class", new VClassTemplateModel(vclass));
|
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("totalCount", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("totalCount") ));
|
||||||
map.put("alpha", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("alpha") ));
|
map.put("alpha", JsonToFmModel.convertJSONObjectToMap( (String) vclassRes.get("alpha") ));
|
||||||
map.put("individuals", JsonToFmModel.convertJSONArrayToList( (JSONArray) vclassRes.get("individuals") ));
|
map.put("individuals", JsonToFmModel.convertJSONArrayToList( (JSONArray) vclassRes.get("individuals") ));
|
||||||
|
|
|
@ -35,7 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
public class JsonServletTest extends AbstractTestClass {
|
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";
|
private static final String GET_VCLASSES_FOR_VCLASS_GROUP = "getVClassesForVClassGroup";
|
||||||
|
|
||||||
|
@ -51,16 +51,16 @@ public class JsonServletTest extends AbstractTestClass {
|
||||||
* ents_edit_head.jsp
|
* ents_edit_head.jsp
|
||||||
* (there is an ents_edit.jsp, invoked from EntityEditController, which does not seem to invoke ents_edit.js)
|
* (there is an ents_edit.jsp, invoked from EntityEditController, which does not seem to invoke ents_edit.js)
|
||||||
*
|
*
|
||||||
* GetSolrIndividualsByVClass
|
* GetSearchIndividualsByVClass
|
||||||
* Mock out SolrServer (from SolrSetup) and IndividualDao
|
* Mock out search engine and IndividualDao
|
||||||
* invoked by BrowseDataGetter.java
|
* invoked by BrowseDataGetter.java
|
||||||
* home page
|
* home page
|
||||||
* invoked by ClassGroupPageData.java
|
* invoked by ClassGroupPageData.java
|
||||||
* >>>> Bring up "People" tab.
|
* >>>> Bring up "People" tab.
|
||||||
* invoked by BrowseWidget.java
|
* invoked by BrowseWidget.java
|
||||||
*
|
*
|
||||||
* GetSolrIndividualsByVClasses
|
* GetSearchIndividualsByVClasses
|
||||||
* Mock out SolrServer (from SolrSetup) and IndividualDao
|
* Mock out search engine and IndividualDao
|
||||||
* invoked by IndividualsForClassesDataGetter.java
|
* invoked by IndividualsForClassesDataGetter.java
|
||||||
* ProcessIndividualsForClasses
|
* ProcessIndividualsForClasses
|
||||||
* extended in vivo by ProcessInternalClasses
|
* extended in vivo by ProcessInternalClasses
|
||||||
|
@ -85,7 +85,7 @@ public class JsonServletTest extends AbstractTestClass {
|
||||||
private WebappDaoFactoryStub wadf;
|
private WebappDaoFactoryStub wadf;
|
||||||
private VClassDaoStub vcDao;
|
private VClassDaoStub vcDao;
|
||||||
|
|
||||||
private SearchEngineStub solr;
|
private SearchEngineStub search;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws ServletException {
|
public void setup() throws ServletException {
|
||||||
|
@ -112,8 +112,8 @@ public class JsonServletTest extends AbstractTestClass {
|
||||||
vcDao = new VClassDaoStub();
|
vcDao = new VClassDaoStub();
|
||||||
wadf.setVClassDao(vcDao);
|
wadf.setVClassDao(vcDao);
|
||||||
|
|
||||||
solr = new SearchEngineStub();
|
search = new SearchEngineStub();
|
||||||
ApplicationStub.setup(new ServletContextStub(), solr);
|
ApplicationStub.setup(new ServletContextStub(), search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -163,7 +163,7 @@ public class JsonServletTest extends AbstractTestClass {
|
||||||
IOException {
|
IOException {
|
||||||
setLoggerLevel(JsonServlet.class, Level.FATAL);
|
setLoggerLevel(JsonServlet.class, Level.FATAL);
|
||||||
setLoggerLevel(JsonObjectProducer.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);
|
servlet.service(req, resp);
|
||||||
assertFailureWithErrorMessage("java.lang.Exception: "
|
assertFailureWithErrorMessage("java.lang.Exception: "
|
||||||
+ "parameter vclassId URI parameter expected ");
|
+ "parameter vclassId URI parameter expected ");
|
||||||
|
@ -175,7 +175,7 @@ public class JsonServletTest extends AbstractTestClass {
|
||||||
setLoggerLevel(JsonServlet.class, Level.FATAL);
|
setLoggerLevel(JsonServlet.class, Level.FATAL);
|
||||||
setLoggerLevel(JsonObjectProducer.class, Level.FATAL);
|
setLoggerLevel(JsonObjectProducer.class, Level.FATAL);
|
||||||
String vclassId = "http://bogusVclass";
|
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);
|
req.addParameter(VCLASS_ID, vclassId);
|
||||||
|
|
||||||
servlet.service(req, resp);
|
servlet.service(req, resp);
|
||||||
|
@ -185,7 +185,8 @@ public class JsonServletTest extends AbstractTestClass {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO test successful responses. This will require figuring out how to
|
* 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.
|
* what sort of NamedList is required as a response to a request.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@ -195,7 +196,7 @@ public class JsonServletTest extends AbstractTestClass {
|
||||||
setLoggerLevel(ModelAccess.class, Level.ERROR);
|
setLoggerLevel(ModelAccess.class, Level.ERROR);
|
||||||
String vclassId = "http://myVclass";
|
String vclassId = "http://myVclass";
|
||||||
vcDao.setVClass(vclassId, new VClass(vclassId));
|
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);
|
req.addParameter(VCLASS_ID, vclassId);
|
||||||
|
|
||||||
servlet.service(req, resp);
|
servlet.service(req, resp);
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -13,7 +13,7 @@ scripts list.-->
|
||||||
"individualsForClasses": "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter",
|
"individualsForClasses": "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter",
|
||||||
"sparqlQuery":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter",
|
"sparqlQuery":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter",
|
||||||
"fixedHtml":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter",
|
"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>
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue