NIHVIVO-2775 Remove Lucene controllers, libraries, and all references to Lucene throughout the code.

This commit is contained in:
ryounes 2011-07-13 15:19:52 +00:00
parent e5ebedf6f5
commit 6083deeaf7
32 changed files with 22 additions and 1031 deletions

View file

@ -33,7 +33,7 @@ webapp.name = vitro
# #
# The location where the Vitro application will store the data that it creates. # The location where the Vitro application will store the data that it creates.
# This includes uploaded files (usually images) and the Lucene search index. # This includes uploaded files (usually images) and the search index.
# #
vitro.home.directory = /usr/local/vitro/data vitro.home.directory = /usr/local/vitro/data

View file

@ -155,12 +155,6 @@
<listener-class> edu.cornell.mannlib.vitro.webapp.auth.policy.RootUserPolicy$Setup</listener-class> <listener-class> edu.cornell.mannlib.vitro.webapp.auth.policy.RootUserPolicy$Setup</listener-class>
</listener> </listener>
<!-- The Lucene index uses a "public" filter, so the PropertyRestrictionPolicyHelper must already be set up. -->
<!--
<listener>
<listener-class> edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneSetup </listener-class>
</listener>
-->
<listener> <listener>
<listener-class> <listener-class>
edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup
@ -874,12 +868,6 @@
<url-pattern>/listObjectPropertyStatements</url-pattern> <url-pattern>/listObjectPropertyStatements</url-pattern>
</servlet-mapping> </servlet-mapping>
<!--
<servlet>
<servlet-name>IndividualListController</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController</servlet-class>
</servlet>
-->
<servlet> <servlet>
<servlet-name>IndividualListController</servlet-name> <servlet-name>IndividualListController</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.SolrIndividualListController</servlet-class> <servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.SolrIndividualListController</servlet-class>
@ -889,12 +877,6 @@
<url-pattern>/individuallist</url-pattern> <url-pattern>/individuallist</url-pattern>
</servlet-mapping> </servlet-mapping>
<!--
<servlet>
<servlet-name>IndividualListRdf</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.EntityURLController</servlet-class>
</servlet>
-->
<servlet> <servlet>
<servlet-name>IndividualListRdf</servlet-name> <servlet-name>IndividualListRdf</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.IndividualListRdfController</servlet-class> <servlet-class>edu.cornell.mannlib.vitro.webapp.controller.IndividualListRdfController</servlet-class>
@ -904,12 +886,6 @@
<url-pattern>/listrdf/*</url-pattern> <url-pattern>/listrdf/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<!--
<servlet>
<servlet-name>SearchController</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.PagedSearchController</servlet-class>
</servlet>
-->
<servlet> <servlet>
<servlet-name>SearchController</servlet-name> <servlet-name>SearchController</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.SolrPagedSearchController</servlet-class> <servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.SolrPagedSearchController</servlet-class>
@ -933,12 +909,6 @@
<url-pattern>/searchcontroller</url-pattern> <url-pattern>/searchcontroller</url-pattern>
</servlet-mapping> </servlet-mapping>
<!--
<servlet>
<servlet-name>AutocompleteController</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.AutocompleteController</servlet-class>
</servlet>
-->
<servlet> <servlet>
<servlet-name>AutocompleteController</servlet-name> <servlet-name>AutocompleteController</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.SolrAutocompleteController</servlet-class> <servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.SolrAutocompleteController</servlet-class>
@ -988,12 +958,6 @@
<url-pattern>/contact</url-pattern> <url-pattern>/contact</url-pattern>
</servlet-mapping> </servlet-mapping>
<!--
<servlet>
<servlet-name>JSON Service</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.JSONServlet</servlet-class>
</servlet>
-->
<servlet> <servlet>
<servlet-name>JSON Service</servlet-name> <servlet-name>JSON Service</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.SolrJsonServlet</servlet-class> <servlet-class>edu.cornell.mannlib.vitro.webapp.controller.SolrJsonServlet</servlet-class>

Binary file not shown.

View file

@ -271,8 +271,6 @@ public class SolrJsonServlet extends VitroHttpServlet {
return map; return map;
} }
//Factoring out to allow for results to be processed from query for both lucene and solr
// Map given to process method includes the actual individuals returned from the search // Map given to process method includes the actual individuals returned from the search
public static JSONObject processVClassResults(Map<String, Object> map, VitroRequest vreq, ServletContext context, boolean multipleVclasses) throws Exception{ public static JSONObject processVClassResults(Map<String, Object> map, VitroRequest vreq, ServletContext context, boolean multipleVclasses) throws Exception{
JSONObject rObj = DataGetterUtils.processVclassResultsJSON(map, vreq, multipleVclasses); JSONObject rObj = DataGetterUtils.processVclassResultsJSON(map, vreq, multipleVclasses);
@ -331,7 +329,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
.getAttribute("displayOntModel"); .getAttribute("displayOntModel");
if (displayOntModel != null) { if (displayOntModel != null) {
ProhibitedFromSearch pfs = new ProhibitedFromSearch( ProhibitedFromSearch pfs = new ProhibitedFromSearch(
DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel); DisplayVocabulary.PRIMARY_SEARCH_INDEX_URI, displayOntModel);
editConfig.setProhibitedFromSearch(pfs); editConfig.setProhibitedFromSearch(pfs);
} }

View file

@ -102,8 +102,6 @@ public class CloneEntityServlet extends BaseEditController {
propertyInstanceDao.insertProp(currPI); propertyInstanceDao.insertProp(currPI);
} }
// addIndividualToLuceneIndex( context, cloneURI );
String encodedCloneURI = URLEncoder.encode(cloneURI, "UTF-8"); String encodedCloneURI = URLEncoder.encode(cloneURI, "UTF-8");
response.sendRedirect("entityEdit?uri="+encodedCloneURI); response.sendRedirect("entityEdit?uri="+encodedCloneURI);
//response.sendRedirect("entity?home="+portalIdStr+"&id="+newEntityId); //response.sendRedirect("entity?home="+portalIdStr+"&id="+newEntityId);

View file

@ -26,7 +26,7 @@ public class DisplayVocabulary {
private static final String NS = DISPLAY_NS; private static final String NS = DISPLAY_NS;
/* Individuals */ /* Individuals */
public static final String PRIMARY_LUCENE_INDEX_URI = NS + "PrimaryLuceneIndex"; public static final String PRIMARY_SEARCH_INDEX_URI = NS + "PrimarySearchIndex";
//bk392 for extracting properties beyond context nodes. //bk392 for extracting properties beyond context nodes.
public static final String CONTEXT_NODES_URI = NS + "QueryForContextNodes"; public static final String CONTEXT_NODES_URI = NS + "QueryForContextNodes";

View file

@ -320,7 +320,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
public void removeClassesHiddenFromSearch(List<VClassGroup> groups) { public void removeClassesHiddenFromSearch(List<VClassGroup> groups) {
OntModel displayOntModel = getOntModelSelector().getDisplayModel(); OntModel displayOntModel = getOntModelSelector().getDisplayModel();
ProhibitedFromSearch pfs = new ProhibitedFromSearch( ProhibitedFromSearch pfs = new ProhibitedFromSearch(
DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel); DisplayVocabulary.PRIMARY_SEARCH_INDEX_URI, displayOntModel);
for (VClassGroup group : groups) { for (VClassGroup group : groups) {
List<VClass> classList = new ArrayList<VClass>(); List<VClass> classList = new ArrayList<VClass>();
for (VClass vclass : group.getVitroClassList()) { for (VClass vclass : group.getVitroClassList()) {

View file

@ -266,7 +266,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
// .getAttribute("displayOntModel"); // .getAttribute("displayOntModel");
// if (displayOntModel != null) { // if (displayOntModel != null) {
// ProhibitedFromSearch pfs = new ProhibitedFromSearch( // ProhibitedFromSearch pfs = new ProhibitedFromSearch(
// DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel); // DisplayVocabulary.PRIMARY_SEARCH_INDEX_URI, displayOntModel);
// if( editConfiguration != null ) // if( editConfiguration != null )
// editConfiguration.setProhibitedFromSearch(pfs); // editConfiguration.setProhibitedFromSearch(pfs);
// } // }

View file

@ -476,7 +476,7 @@ public class MenuEditingFormGenerator implements EditConfigurationGenerator {
.getAttribute("displayOntModel"); .getAttribute("displayOntModel");
if (displayOntModel != null) { if (displayOntModel != null) {
ProhibitedFromSearch pfs = new ProhibitedFromSearch( ProhibitedFromSearch pfs = new ProhibitedFromSearch(
DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel); DisplayVocabulary.PRIMARY_SEARCH_INDEX_URI, displayOntModel);
if( editConfiguration != null ) if( editConfiguration != null )
editConfiguration.setProhibitedFromSearch(pfs); editConfiguration.setProhibitedFromSearch(pfs);
} }

View file

@ -5,7 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.search;
public class VitroSearchTermNames { public class VitroSearchTermNames {
/** Id of entity, vclass or tab */ /** Id of entity, vclass or tab */
public static String URI = "URI"; public static String URI = "URI";
/** lucene document id */ /** search document id */
public static String DOCID = "DocId"; public static String DOCID = "DocId";
/** java class of the object that the Doc represents. */ /** java class of the object that the Doc represents. */
public static String JCLASS = "JCLASS"; public static String JCLASS = "JCLASS";

View file

@ -1,51 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.beans;
import java.util.List;
import edu.cornell.mannlib.vitro.webapp.search.SearchException;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroHighlighter;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQuery;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQueryFactory;
/**
* This is used by the SearchController. Any search back end should
* implement this.
*
* Currently we use LuceneSearcher. It gets setup by LuceneSetup which
* is specified to run as a listener in the application's web.xml.
*
* @author bdc34
*
* @ deprecated Use LuceneIndexFactory instead
*/
public interface Searcher {
public VitroQueryFactory getQueryFactory();
/**
* return a list of object that are related to the query.
* The objects should be of type Entity or Tab, if not they
* will be ignored.
* @param query
* @return
* @throws SearchException
*/
public List search( VitroQuery query ) throws SearchException;
/**
* The searcher may need to be used when making a highlighter.
* In Lucene the highlighter needs access to the index.
* @param q
* @return
*/
// public abstract VitroHighlighter getHighlighter(VitroQuery q);
/**
* Used to close the searcher if the index that it was using gets
* deleted.
*/
public void close();
}

View file

@ -1,134 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.beans;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.sf.jga.fn.UnaryFunctor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
/**
* Interface for classes that highlight search results.
* All method must gracefully deal with null inputs.
*
* @author bdc34
*
* @ deprecated there is no replacement
*/
public abstract class VitroHighlighter extends UnaryFunctor<String,String> {
private static final Log log = LogFactory.getLog(VitroHighlighter.class.getName());
public static String preTag = "<span class='SearchTerm'>";
public static String postTag = "</span>";
public abstract String highlight(String in );
public abstract String getHighlightFragments(String in );
public String fn(String in){
if( in == null || "".equals(in))
return "";
try{
return highlight( in );
}catch(Throwable th){
return in;
}
}
public void highlight(Individual ent){
if( ent == null)
return;
ent.setName( this.highlight(ent.getName()));
Iterator edIt = ent.getDataPropertyStatements().iterator();
while (edIt.hasNext()) {
DataPropertyStatement dataPropertyStmt = (DataPropertyStatement)edIt.next();
dataPropertyStmt.setData(this.highlight(dataPropertyStmt.getData()));
}
edIt = ent.getObjectPropertyStatements().iterator();
/* works only if JSP doesn't escape the text
while (edIt.hasNext()) {
ObjectPropertyStatement objectPropertyStmt = (ObjectPropertyStatement)edIt.next();
Individual object = objectPropertyStmt.getObject();
object.setName(this.highlight(object.getName()));
}
*/
}
/**
* Highlights the name and then replaces the description with
* highlighted fragments.
* @param ent
*/
public void fragmentHighlight(Individual ent){
if( ent == null )
return;
//highlight the name, anchor and moniker and place back in entity object
if( ent.getName() != null )
ent.setName( highlight( stripHtml(ent.getName() )));
//make a buffer of text to use the fragmenting hightlighter on
StringBuffer sb = new StringBuffer("");
if(ent.getDataPropertyStatements() != null) {
Iterator edIt = ent.getDataPropertyStatements().iterator();
while (edIt.hasNext()) {
sb.append(((DataPropertyStatement)edIt.next()).getData());
sb.append(' ');
}
}
if(ent.getObjectPropertyStatements() != null) {
Iterator edIt = ent.getObjectPropertyStatements().iterator();
while (edIt.hasNext()) {
String t;
try {
ObjectPropertyStatement stmt = (ObjectPropertyStatement) edIt.next();
sb.append( ( (t = stmt.getProperty().getDomainPublic()) != null) ? t : "" );
sb.append(' ');
sb.append( ( (t = stmt.getObject().getName()) != null) ? t : "" );
sb.append(' ');
} catch (Exception e) {
log.info("Error highlighting object property statement for individual "+ent.getURI());
}
}
}
}
private final String stripHtml(String in){
/* make a string with html stripped out */
// ryounes 5/16/2011 Broken with upgrade to Solr 3.1: HTMLStripReader has been removed.
// According to change list, should use HTMLStripCharFilter, but it's not immediately clear how
// to migrate this code. Will enter Jira issue.
// Reader stripIn = new HTMLStripReader( new StringReader( in ) );
// StringWriter stripOut = new StringWriter(in.length());
//
// char bytes[] = new char[5000];
// int bytesRead = 0;
// try {
// //this is a mess, there must be a better way to do this.
// while ( true ){
// bytesRead = stripIn.read( bytes );
// if( bytesRead == -1 ) break;
// stripOut.write(bytes, 0, bytesRead );
// }
// } catch (IOException e1) {
// log.error("LuceneHighlighter.getHighlightFragments()" +
// " - unable to strip html" + e1);
// }
// return stripOut.toString();
return in;
}
}

View file

@ -13,14 +13,12 @@ public class VitroQueryWrapper {
private VitroQuery query = null; private VitroQuery query = null;
private int requestCount = 0; private int requestCount = 0;
private long searchTime = 0; private long searchTime = 0;
private VitroHighlighter highlighter;
public VitroQueryWrapper(VitroQuery q, VitroHighlighter hi, int reqCount, long d){ public VitroQueryWrapper(VitroQuery q, int reqCount, long d){
this.setSearchTime(d); this.setSearchTime(d);
this.setQuery(q); this.setQuery(q);
this.setRequestCount(reqCount); this.setRequestCount(reqCount);
this.highlighter = hi;
} }
public long getSearchTime() { public long getSearchTime() {
@ -42,6 +40,4 @@ public class VitroQueryWrapper {
this.requestCount = requestCount; this.requestCount = requestCount;
} }
public VitroHighlighter getHighlighter(){ return highlighter; }
} }

View file

@ -24,8 +24,8 @@ import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
* *
* That IndexBuilder will be associated with a object that implements the IndexerIface. * That IndexBuilder will be associated with a object that implements the IndexerIface.
* *
* An example of the IndexerIface is LuceneIndexer. * An example of the IndexerIface is SolrIndexer.
* An example of the IndexBuilder and LuceneIndexer getting setup is in LuceneSetup. * An example of the IndexBuilder and SolrIndexer setup is in SolrSetup.
* *
* @author bdc34 * @author bdc34
*/ */

View file

@ -47,7 +47,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.search.IndexConstants; import edu.cornell.mannlib.vitro.webapp.search.IndexConstants;
import edu.cornell.mannlib.vitro.webapp.search.SearchException; import edu.cornell.mannlib.vitro.webapp.search.SearchException;
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames; import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroHighlighter;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQuery; import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQuery;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQueryFactory; import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQueryFactory;
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup; import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
@ -63,8 +62,6 @@ import freemarker.template.Configuration;
* *
*/ */
// This will be renamed to PagedSearchController once everything is using Solr and we can
// delete the Lucene version.
public class SolrPagedSearchController extends FreemarkerHttpServlet { public class SolrPagedSearchController extends FreemarkerHttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -615,10 +612,6 @@ public class SolrPagedSearchController extends FreemarkerHttpServlet {
public static final int MAX_QUERY_LENGTH = 500; public static final int MAX_QUERY_LENGTH = 500;
public VitroHighlighter getHighlighter(VitroQuery q) {
throw new Error("PagedSearchController.getHighlighter() is unimplemented");
}
public VitroQueryFactory getQueryFactory() { public VitroQueryFactory getQueryFactory() {
throw new Error("PagedSearchController.getQueryFactory() is unimplemented"); throw new Error("PagedSearchController.getQueryFactory() is unimplemented");
} }

View file

@ -22,7 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
* The IndexBuilder is used to rebuild or update a search index. * The IndexBuilder is used to rebuild or update a search index.
* There should only be one IndexBuilder in a vitro web application. * There should only be one IndexBuilder in a vitro web application.
* It uses an implementation of a back-end through an object that * It uses an implementation of a back-end through an object that
* implements IndexerIface. An example of a back-end is LuceneIndexer. * implements IndexerIface. An example of a back-end is SolrIndexer.
* *
* See the class SearchReindexingListener for an example of how a model change * See the class SearchReindexingListener for an example of how a model change
* listener can use an IndexBuilder to keep the full text index in sncy with * listener can use an IndexBuilder to keep the full text index in sncy with

View file

@ -13,8 +13,8 @@ import edu.cornell.mannlib.vitro.webapp.search.docbuilder.Obj2DocIface;
* IndexBuilder will manage getting lists of object to index and then use * IndexBuilder will manage getting lists of object to index and then use
* an object that implements IndexerIface to stuff the backend index. * an object that implements IndexerIface to stuff the backend index.
* *
* An example is LuceneIndexer which is set up and associated with a * An example is SolrIndexer which is set up and associated with a
* IndexBuilder in LuceneSetup. * IndexBuilder in SolrSetup.
* *
* @author bdc34 * @author bdc34
* *

View file

@ -1,65 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.lucene;
import org.apache.lucene.search.DefaultSimilarity;
public class CustomSimilarity extends DefaultSimilarity {
public CustomSimilarity(){}
/**
* According to Lucene Javadoc, idf computes a score factor
* based on a term's document frequency (the number of documents
* that contain the term).
*
* idf = log(numDocs/(docFreq + 1))
*
* From this formula we see that, the lower the value of docFreq
* higher the value of idf. In other words, rare terms have higher
* idf scores.
*
* Returning a value of 1.0f here for idf, since we wan't the
* rarity of a term not to effect the score of a document.
*
* bk392 3/29/2011
*/
@Override
public float idf(int docFreq, int numDocs){
return 1.0f;
}
/**
* Coord computes a score factor based on the fraction of all query terms
* that a document contains. The default implementation is
*
* coord = (overlap/ maxOverlap)
*
* overlap is the number of queryterms matched in the document and maxOverlap
* is the total number of terms present in the query. That means, more number of
* query terms matched in a document, higher the score. Here, we are returning a
* value of 1.0f to override this effect.
*/
@Override
public float coord(int overlap, int maxOverlap){
return 1.0f;
}
/**
* From Lucene Javadoc, lengthNorm computes the normalization value
* for a given field. These values together with the field boosts, are
* stored in an index and multiplied into scores for hits on each field by
* the search code.
*
* lengthNorm = 1 / sqrt(numTerms)
*
* In other words, the document score is inversely proportional to the number of terms
* contained in the field of interest. Higher the number, lower the doc score. We don't
* want this since most of our fields contain single value. (except ALLTEXT and type)
*/
@Override
public float lengthNorm(String fieldName, int numTerms){
return 1.0f;
}
}

View file

@ -1,375 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.lucene;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.Term;
import org.joda.time.DateTime;
import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
import edu.cornell.mannlib.vitro.webapp.search.beans.IndividualProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.search.docbuilder.Obj2DocIface;
/**
* This class expect that Entities passed to it will have
* a VClass object and a list of keywords. The entity should
* be as full as possible.
*/
public class Entity2LuceneDoc implements Obj2DocIface{
/** These are the terms for the lucene index */
public static class VitroLuceneTermNames{
/** Id of entity, vclass or tab */
public static String URI = "URI";
/** lucene document id */
public static String DOCID = "DocId";
/** java class of the object that the Doc represents. */
public static String JCLASS = "JCLASS";
/** rdf:type */
public static String RDFTYPE = "type";
/** rdf:type */
public static String CLASSGROUP_URI = "classgroup";
/** Modtime from db */
public static String MODTIME = "modTime";
/** time of index in msec since epoc */
public static String INDEXEDTIME= "indexedTime";
/** text for 'full text' search, this is stemmed */
public static String ALLTEXT = "ALLTEXT";
/** text for 'full text' search, this is unstemmed for
* use with wildcards and prefix queries */
public static String ALLTEXTUNSTEMMED = "ALLTEXTUNSTEMMED";
/** class name for storing context nodes **/
public static final String CONTEXTNODE = "contextNode";
/** Does the individual have a thumbnail image? 1=yes 0=no */
public static final String THUMBNAIL = "THUMBNAIL";
/** Should individual be included in full text search results? 1=yes 0=no */
public static final String PROHIBITED_FROM_TEXT_RESULTS = "PROHIBITED_FROM_TEXT_RESULTS";
/** class names in human readable form of an individual*/
public static final String CLASSLOCALNAMELOWERCASE = "classLocalNameLowerCase";
/** class names in human readable form of an individual*/
public static final String CLASSLOCALNAME = "classLocalName";
// Fields derived from rdfs:label
/** Raw rdfs:label: no lowercasing, no tokenizing, no stop words, no stemming.
* Used only in retrieval rather than search. **/
public static String NAME_RAW = "nameRaw"; // was NAMERAW
/** rdfs:label lowercased, no tokenizing, no stop words, no stemming **/
public static String NAME_LOWERCASE = "nameLowercase"; // was NAMELOWERCASE
/** Same as NAME_LOWERCASE, but single-valued so it's sortable. **/
// RY Need to control how indexing selects which of multiple values to copy.
public static String NAME_LOWERCASE_SINGLE_VALUED = "nameLowercaseSingleValued";
/** rdfs:label lowercased, tokenized, stop words, no stemming.
* Used for autocomplete matching on proper names. **/
public static String NAME_UNSTEMMED = "nameUnstemmed"; // was NAMEUNSTEMMED
/** rdfs:label lowercased, tokenized, stop words, stemmed.
* Used for autocomplete matching where stemming is desired (e.g., book titles) **/
public static String NAME_STEMMED = "nameStemmed"; // was NAME
}
private static final Log log = LogFactory.getLog(Entity2LuceneDoc.class.getName());
public static String earliestTime = "16000101";
public static String latestTime = "30000101";
/** a way to get to the term names for the lucene index */
public static VitroLuceneTermNames term = new VitroLuceneTermNames();
private static String entClassName = Individual.class.getName();
private ProhibitedFromSearch classesProhibitedFromSearch;
private IndividualProhibitedFromSearch individualProhibited;
private static HashMap<String, String> IndividualURIToObjectProperties = new HashMap<String, String>();
private static HashSet<String> objectProperties = new HashSet<String>();
public Entity2LuceneDoc(
ProhibitedFromSearch classesProhibitedFromSearch,
IndividualProhibitedFromSearch individualProhibited){
this.classesProhibitedFromSearch = classesProhibitedFromSearch;
this.individualProhibited = individualProhibited;
}
public boolean canTranslate(Object obj) {
return (obj != null && obj instanceof Individual);
}
@SuppressWarnings("static-access")
public Object translate(Object obj) throws IndexingException {
if(!( obj instanceof Individual))
return null;
Individual ent = (Individual)obj;
String value;
Document doc = new Document();
String classPublicNames = "";
//DocId
String id = ent.getURI();
log.debug("translating " + id);
if( id == null ){
log.debug("cannot add individuals without URIs to lucene index");
return null;
}else if( id.startsWith( VitroVocabulary.vitroURI )
|| id.startsWith( VitroVocabulary.VITRO_PUBLIC )
|| id.startsWith( VitroVocabulary.PSEUDO_BNODE_NS)
|| id.startsWith( OWL.NS ) ){
log.debug("not indxing because of namespace:" + id );
return null;
}
//filter out class groups, owl:ObjectProperties etc.
if( individualProhibited.isIndividualProhibited( id ) ){
return null;
}
/* Types and ClassGroup */
boolean prohibited = false;
List<VClass> vclasses = ent.getVClasses(false);
for( VClass clz : vclasses){
if( clz.getURI() == null ){
continue;
}else if( OWL.Thing.getURI().equals( clz.getURI()) ){
//index individuals of type owl:Thing, just don't add owl:Thing the type field in the index
continue;
} else if ( clz.getURI().startsWith( OWL.NS ) ){
log.debug("not indexing " + id + " because of type " + clz.getURI());
return null;
}else{
if( !prohibited && classesProhibitedFromSearch.isClassProhibitedFromSearch(clz.getURI()) )
prohibited = true;
if( clz.getSearchBoost() != null )
doc.setBoost( doc.getBoost() + clz.getSearchBoost() );
Field typeField = new Field (term.RDFTYPE, clz.getURI(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
doc.add( typeField);
if(clz.getLocalName() != null){
Field classLocalName = new Field(term.CLASSLOCALNAME, clz.getLocalName(), Field.Store.YES, Field.Index.ANALYZED);
Field classLocalNameLowerCase = new Field(term.CLASSLOCALNAMELOWERCASE, clz.getLocalName().toLowerCase(), Field.Store.YES, Field.Index.ANALYZED);
doc.add(classLocalName);
doc.add(classLocalNameLowerCase);
}
if( clz.getName() != null )
classPublicNames = classPublicNames + " " + clz.getName();
//Classgroup URI
if( clz.getGroupURI() != null ){
Field classGroupField = new Field(term.CLASSGROUP_URI, clz.getGroupURI(),
Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
// classGroupField.setBoost(FIELD_BOOST);
doc.add(classGroupField);
}
}
}
doc.add( new Field(term.PROHIBITED_FROM_TEXT_RESULTS, prohibited?"1":"0",
Field.Store.NO,Field.Index.NOT_ANALYZED_NO_NORMS) );
/* lucene DOCID */
doc.add( new Field(term.DOCID, entClassName + id,
Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
//vitro Id
doc.add( new Field(term.URI, id, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
//java class
doc.add( new Field(term.JCLASS, entClassName, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
// Individual label
if( ent.getRdfsLabel() != null )
value=ent.getRdfsLabel();
else{
//log.debug("Skipping individual without rdfs:label " + ent.getURI());
//return null;
log.debug("Using local name for individual with rdfs:label " + ent.getURI());
value = ent.getLocalName();
}
Field nameRaw = new Field(term.NAME_RAW, value, Field.Store.YES, Field.Index.NOT_ANALYZED);
nameRaw.setBoost(NAME_BOOST);
doc.add(nameRaw);
// RY Not sure if we need to store this. For Solr, see schema.xml field definition.
Field nameLowerCase = new Field(term.NAME_LOWERCASE, value.toLowerCase(), Field.Store.YES, Field.Index.NOT_ANALYZED);
nameLowerCase.setBoost(NAME_BOOST);
doc.add(nameLowerCase);
Field nameUnstemmed = new Field(term.NAME_UNSTEMMED, value, Field.Store.NO, Field.Index.ANALYZED);
nameUnstemmed.setBoost(NAME_BOOST);
doc.add(nameUnstemmed);
Field nameStemmed = new Field(term.NAME_STEMMED, value, Field.Store.NO, Field.Index.ANALYZED);
nameStemmed.setBoost(NAME_BOOST);
doc.add(nameStemmed);
String contextNodePropertyValues;
// if(ent.isVClass("http://xmlns.com/foaf/0.1/Person")){
/*contextNodePropertyValues = searchQueryHandler.getPropertiesAssociatedWithEducationalTraining(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithRole(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithPosition(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithRelationship(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithAwardReceipt(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithInformationResource(ent.getURI()); */
// }
/* Field contextNodeInformation = new Field(term.CONTEXTNODE, contextNodePropertyValues, Field.Store.YES, Field.Index.ANALYZED );
doc.add(contextNodeInformation);*/
//boost for entity
if( ent.getSearchBoost() != null && ent.getSearchBoost() != 0 )
doc.setBoost(ent.getSearchBoost());
//Modification time
// if( ent.getModTime() != null){
// value = (new DateTime(ent.getModTime().getTime()))
// .toString(LuceneIndexer.MODTIME_DATE_FORMAT) ;
// } else {
// value= (new DateTime()).toString(LuceneIndexer.MODTIME_DATE_FORMAT) ;
// }
// doc.add( new Field(term.MODTIME, value , Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
/* thumbnail */
try{
value = null;
if( ent.hasThumb() )
doc.add(new Field(term.THUMBNAIL, "1", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
else
doc.add(new Field(term.THUMBNAIL, "0", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
}catch(Exception ex){
log.debug("could not index thumbnail: " + ex);
}
//time of index in millis past epoc
Object anon[] = { new Long((new DateTime() ).getMillis()) };
doc.add( new Field(term.INDEXEDTIME, String.format( "%019d", anon ),
Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
if( ! prohibited ){
//ALLTEXT, all of the 'full text'
String t=null;
value ="";
value+= " "+( ((t=ent.getName()) == null)?"":t );
value+= " "+ getKeyterms(ent);
value+= " " + classPublicNames;
List<DataPropertyStatement> dataPropertyStatements = ent.getDataPropertyStatements();
if (dataPropertyStatements != null) {
Iterator<DataPropertyStatement> dataPropertyStmtIter = dataPropertyStatements.iterator();
while (dataPropertyStmtIter.hasNext()) {
DataPropertyStatement dataPropertyStmt = dataPropertyStmtIter.next();
value+= " "+ ( ((t=dataPropertyStmt.getData()) == null)?"":t );
}
}
List<ObjectPropertyStatement> objectPropertyStatements = ent.getObjectPropertyStatements();
if (objectPropertyStatements != null) {
Iterator<ObjectPropertyStatement> objectPropertyStmtIter = objectPropertyStatements.iterator();
while (objectPropertyStmtIter.hasNext()) {
ObjectPropertyStatement objectPropertyStmt = objectPropertyStmtIter.next();
if( "http://www.w3.org/2002/07/owl#differentFrom".equals(objectPropertyStmt.getPropertyURI()) )
continue;
try {
value+= " "+ ( ((t=objectPropertyStmt.getObject().getName()) == null)?"":t );
if(ent.isVClass("http://xmlns.com/foaf/0.1/Person")){
//IndividualURIToObjectProperties.put(ent.getURI(), ( ((t=objectPropertyStmt.getProperty().getURI()) == null)?"":t ) );
objectProperties.add(( ((t=objectPropertyStmt.getProperty().getURI()) == null)?"":t ));
}
} catch (Exception e) {
log.debug("could not index name of related object: " + e.getMessage());
}
}
}
//stemmed terms
doc.add( new Field(term.ALLTEXT, value , Field.Store.NO, Field.Index.ANALYZED));
//unstemmed terms
doc.add( new Field(term.ALLTEXTUNSTEMMED, value, Field.Store.NO, Field.Index.ANALYZED));
}
// log.info("\n IndividualURItoObjectProperties " + IndividualURIToObjectProperties.toString() + " \n\n");
log.info(" \n Object Properties " + objectProperties.toString() + "\n\n");
return doc;
}
@SuppressWarnings("static-access")
public boolean canUnTranslate(Object result) {
if( result != null && result instanceof Document){
Document hit = (Document) result;
if( entClassName.equalsIgnoreCase(hit.get(term.JCLASS)) ){
return true;
}
}
return false;
}
@SuppressWarnings("static-access")
public Object unTranslate(Object result) {
Individual ent = null;
if( result != null && result instanceof Document){
Document hit = (Document) result;
String id = hit.get(term.URI);
ent = new IndividualImpl();
ent.setURI(id);
}
return ent;
}
@SuppressWarnings("static-access")
public Object getIndexId(Object obj) {
return new Term(term.DOCID, entClassName + ((Individual)obj).getURI() ) ;
}
private String getKeyterms(Individual ent){
/* bdc34: vitro:keywords are no longer being indexed */
return "";
}
public ProhibitedFromSearch getClassesProhibitedFromSearch() {
return classesProhibitedFromSearch;
}
public void setClassesProhibitedFromSearch(
ProhibitedFromSearch classesProhibitedFromSearch) {
this.classesProhibitedFromSearch = classesProhibitedFromSearch;
}
public static float NAME_BOOST = 3.0F;
public static float MONIKER_BOOST = 2.0F;
public static float FIELD_BOOST = 1.0F;
}

View file

@ -1,121 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.lucene;
import java.io.Reader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.lucene.analysis.ASCIIFoldingFilter;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.LowerCaseFilter;
import org.apache.lucene.analysis.StopFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.standard.StandardFilter;
import org.apache.lucene.analysis.standard.StandardTokenizer;
import org.apache.lucene.util.Version;
public class HtmlLowerStopAnalyzer extends Analyzer {
/* much of this code is from
* http://www.onjava.com/pub/a/onjava/2003/01/15/lucene.html?page=2
* bdc34
*/
private static Set<String> _stopWords;
/**
* An array containing some common English words
* that are usually not useful for searching.
*/
public static final String[] STOP_WORDS =
{
"0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "000", "$",
"about", "after", "all", "also", "an", "and",
"another", "any", "are", "as", "at", "be",
"because", "been", "before", "being", "between",
"both", "but", "by", "came", "can", "come",
"could", "did", "do", "does", "each", "else",
"for", "from", "get", "got", "has", "had",
"he", "have", "her", "here", "him", "himself",
"his", "how","if", "in", "into", "is", "it",
"its", "just", "like", "make", "many", "me",
"might", "more", "most", "much", "must", "my",
"never", "now", "of", "on", "only", "or",
"other", "our", "out", "over", "re", "said",
"same", "see", "should", "since", "so", "some",
"still", "such", "take", "than", "that", "the",
"their", "them", "then", "there", "these",
"they", "this", "those", "through", "to", "too",
"under", "up", "use", "very", "want", "was",
"way", "we", "well", "were", "what", "when",
"where", "which", "while", "who", "will",
"with", "would", "you", "your",
"a", "b", "c", "d", "e", "f", "g", "h", "i",
"j", "k", "l", "m", "n", "o", "p", "q", "r",
"s", "t", "u", "v", "w", "x", "y", "z"
};
public static final List<String> stopWordsList = Arrays.asList(STOP_WORDS);
public static final Set<String> STOP_WORDS_SET = new HashSet<String>(stopWordsList);
/**
* Builds an analyzer.
*/
public HtmlLowerStopAnalyzer()
{
this(STOP_WORDS_SET);
}
/**
* Builds an analyzer with the given stop words.
*
* @param stopWords a String array of stop words
*/
public HtmlLowerStopAnalyzer(Set<String> stopWords)
{
_stopWords = STOP_WORDS_SET;
}
/**
* Processes the input by first converting it to
* lower case, then by eliminating stop words.
*
* @param reader the Reader that
* provides access to the input text
* @return an instance of TokenStream
*/
public TokenStream tokenStream(String fieldName, Reader arg0) {
//ignore fieldName, tokenize all fields the same way.
/* With this we are pipeing the output of the inner most
* Reader outwards.
* Input-> HtmlStrip-> LowerCase-> stopFilter-> StemFilter-> Output
*/
// TokenStream htmlStripAndLower =
// new LowerCaseTokenizer(arg0 );
//
//
// boolean IGNORE_CASE = true;
// TokenFilter stopFilter =
// new StopFilter(htmlStripAndLower,STOP_WORDS , IGNORE_CASE) ;
//
// return stopFilter;
//
TokenStream result = new StandardTokenizer(Version.LUCENE_29, arg0);
result = new StandardFilter(result); //break into tokens
result = new LowerCaseFilter(result); //lower case
result = new StopFilter(ENABLE_POSITION_INCREMENTS, result, STOP_WORDS_SET, IGNORE_CASE); //remove stop words
result = new ASCIIFoldingFilter(result); //this class converts alphabetic, symbolic and numerical characters into their ASCII equivalents.
return result;
}
private static final boolean IGNORE_CASE = true;
private static final boolean ENABLE_POSITION_INCREMENTS = false;
}

View file

@ -1,47 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.lucene;
import java.io.Reader;
import java.util.Set;
import org.apache.lucene.analysis.PorterStemFilter;
import org.apache.lucene.analysis.TokenStream;
/**
* A Analyzer that strips html, lower cases, removes stops and
* then does porter stemming.
*
* @author bdc34
*
*/
public class HtmlLowerStopStemAnalyzer extends HtmlLowerStopAnalyzer {
public HtmlLowerStopStemAnalyzer(){
super();
}
public HtmlLowerStopStemAnalyzer(Set<String> stopWords){
super(stopWords);
}
/**
* Processes the input by first converting it to
* lower case, then by eliminating stop words, and
* finally by performing Porter stemming on it.
*
* @param reader the Reader that
* provides access to the input text
* @return an instance of TokenStream
*/
public TokenStream tokenStream(String fieldName, Reader arg0) {
//ignore fieldName, tokenize all fields the same way.
/* With this we are pipeing the output of the inner most
* Reader outwards.
* Input-> HtmlStrip-> LowerCase-> stopFilter-> StemFilter-> Output
*/
return new PorterStemFilter(super.tokenStream(fieldName,arg0));
}
}

View file

@ -1,123 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.lucene;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.search.SearchException;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQuery;
/**
* Creates a query that can be used to search a Lucene index.
* This class uses the Lucene class QueryParser to parse the
* text from the html text field input form.
*
* For information about how syntaxt and semantics of the
* QueryParser see:
* http://lucene.apache.org/java/docs/queryparsersyntax.html
* http://today.java.net/pub/a/today/2003/11/07/QueryParserRules.html
*
* This class is not thread safe, use one instance per request.
* @author bdc34
*
*/
public class LuceneQuery extends VitroQuery {
private final String defaultSearchField = "ALLTEXT";
private final int SIMPLE = 1;
private final int ADVANCED =2;
private int queryType = SIMPLE;
private Query query = null;
private Analyzer analyzer = null;
private static final Log log = LogFactory.getLog(LuceneQuery.class.getName());
public LuceneQuery(VitroRequest request,
Analyzer analyzer,
String defaultField ){
super(request); //the super class will stash the parameters for us.
this.analyzer = analyzer;
if( isAdvancedQuery( request ) ){
queryType = ADVANCED;
}
}
@SuppressWarnings("static-access")
private QueryParser getQueryParser(){
//defaultSearchField indicates which field search against when there is no term
//indicated in the query string.
//The analyzer is needed so that we use the same analyzer on the search queries as
//was used on the text that was indexed.
QueryParser qp = new QueryParser(defaultSearchField,analyzer);
//this sets the query parser to AND all of the query terms it finds.
qp.setDefaultOperator(QueryParser.AND_OPERATOR);
return qp;
}
public Object getQuery() throws SearchException {
if( this.query != null )
return this.query;
String querystr = "";
if( getParameters() != null && getParameters().get(VitroQuery.QUERY_PARAMETER_NAME)!=null ){
Object obj= getParameters().get(VitroQuery.QUERY_PARAMETER_NAME);
if( obj instanceof String[])
querystr = ((String[])obj)[0];
else
log.debug("LuceneQquery.getQuery() querytext is of class " +
obj.getClass().getName());
}
else
throw new SearchException(this.getClass().getName() +
": There was no Parameter '"+VitroQuery.QUERY_PARAMETER_NAME+"' in the request.");
try{
if( SIMPLE == queryType ){
QueryParser parser= getQueryParser();
this.query = parser.parse(querystr);
} else if( ADVANCED == queryType ){
this.query = null;
}
}catch (Exception ex){
throw new SearchException(ex.getMessage());
}
return this.query;
}
/**
* Check to see if the request came from some sort of advanced query page.
*
* @param request
* @return
*/
private boolean isAdvancedQuery(HttpServletRequest request){
return false;
}
@Override
public String getTerms() {
if( getParameters() != null &&
getParameters().get(VitroQuery.QUERY_PARAMETER_NAME) != null) {
Object terms = getParameters().get(VitroQuery.QUERY_PARAMETER_NAME);
if( terms instanceof String[] ) {
return ((String[])terms)[0];
} else {
log.debug("LuceneQuery.getTerms(): terms in a " + terms.getClass().getName() );
return "";
}
} else
return "";
}
public Analyzer getAnalyzer(){return analyzer;}
}

View file

@ -1,40 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.lucene;
import org.apache.lucene.analysis.Analyzer;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.search.SearchException;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQuery;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQueryFactory;
public class LuceneQueryFactory implements VitroQueryFactory {
public static final int MAX_QUERY_LENGTH = 500;
private String defaultField;
private Analyzer analyzer = null;
public LuceneQueryFactory(Analyzer analyzer, String defaultField ){
this.analyzer = analyzer;
this.defaultField = defaultField;
}
public VitroQuery getQuery(VitroRequest request) throws SearchException {
//there should be a better way to integrate this with LuceneQuery
//here we check that the request has the parameters that we need to
//make the query. If it does not then we return null.
String txt = request.getParameter(VitroQuery.QUERY_PARAMETER_NAME);
if( txt == null || txt.length() == 0 )
return null;
if( txt.length() > MAX_QUERY_LENGTH )
throw new SearchException("The search was too long. The maximum " +
"query length is " + MAX_QUERY_LENGTH );
LuceneQuery query = new LuceneQuery(request, analyzer, defaultField );
return query;
}
public Analyzer getAnalyzer(){
return analyzer;
}
}

View file

@ -134,7 +134,7 @@ public class IndividualToSolrDocument {
private void checkForSkipBasedOnNS(Individual ind) throws SkipIndividualException { private void checkForSkipBasedOnNS(Individual ind) throws SkipIndividualException {
String id = ind.getURI(); String id = ind.getURI();
if(id == null){ if(id == null){
throw new SkipIndividualException("cannot add individuals without URIs to lucene Index"); throw new SkipIndividualException("cannot add individuals without URIs to search index");
}else if( id.startsWith(VitroVocabulary.vitroURI) || }else if( id.startsWith(VitroVocabulary.vitroURI) ||
id.startsWith(VitroVocabulary.VITRO_PUBLIC) || id.startsWith(VitroVocabulary.VITRO_PUBLIC) ||
id.startsWith(VitroVocabulary.PSEUDO_BNODE_NS) || id.startsWith(VitroVocabulary.PSEUDO_BNODE_NS) ||

View file

@ -71,7 +71,6 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
context.setAttribute(LOCAL_SOLR_SERVER, server); context.setAttribute(LOCAL_SOLR_SERVER, server);
/* set up the individual to solr doc translation */ /* set up the individual to solr doc translation */
//first we need a ent2luceneDoc translator
OntModel displayOntModel = (OntModel) sce.getServletContext().getAttribute("displayOntModel"); OntModel displayOntModel = (OntModel) sce.getServletContext().getAttribute("displayOntModel");
OntModel abox = ModelContext.getBaseOntModelSelector(context).getABoxModel(); OntModel abox = ModelContext.getBaseOntModelSelector(context).getABoxModel();
@ -86,7 +85,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
modifiers.add(new NameBoost()); modifiers.add(new NameBoost());
IndividualToSolrDocument indToSolrDoc = new IndividualToSolrDocument( IndividualToSolrDocument indToSolrDoc = new IndividualToSolrDocument(
new ProhibitedFromSearch(DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel), new ProhibitedFromSearch(DisplayVocabulary.PRIMARY_SEARCH_INDEX_URI, displayOntModel),
new IndividualProhibitedFromSearchImpl(context), new IndividualProhibitedFromSearchImpl(context),
modifiers); modifiers);

View file

@ -449,7 +449,7 @@ public class InputElementFormattingTag extends TagSupport {
.getAttribute("displayOntModel"); .getAttribute("displayOntModel");
if (displayOntModel != null) { if (displayOntModel != null) {
ProhibitedFromSearch pfs = new ProhibitedFromSearch( ProhibitedFromSearch pfs = new ProhibitedFromSearch(
DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel); DisplayVocabulary.PRIMARY_SEARCH_INDEX_URI, displayOntModel);
if( editConfig != null ) if( editConfig != null )
editConfig.setProhibitedFromSearch(pfs); editConfig.setProhibitedFromSearch(pfs);
} }

View file

@ -30,7 +30,6 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
private final String objectUri; private final String objectUri;
private final String templateName; private final String templateName;
//Updating to include Vitro Request
ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String objectKey, ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String objectKey,
Map<String, String> data, EditingPolicyHelper policyHelper, String templateName, VitroRequest vreq) { Map<String, String> data, EditingPolicyHelper policyHelper, String templateName, VitroRequest vreq) {
super(subjectUri, propertyUri, policyHelper, vreq); super(subjectUri, propertyUri, policyHelper, vreq);

View file

@ -110,7 +110,7 @@ public class ProhibitedFromSearchTest {
@Test @Test
public void testPrimaryIndex(){ public void testPrimaryIndex(){
String primaryIndexN3 = String primaryIndexN3 =
"<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#PrimaryLuceneIndex>" + "<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#PrimarySearchIndex>" +
"<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#excludeClass>" + "<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#excludeClass>" +
"<http://vivoweb.org/ontology/core#NonAcademic> . "; "<http://vivoweb.org/ontology/core#NonAcademic> . ";
@ -119,7 +119,7 @@ public class ProhibitedFromSearchTest {
m.add( r.listStatements() ); m.add( r.listStatements() );
Assert.assertTrue(m.size() == 1); Assert.assertTrue(m.size() == 1);
ProhibitedFromSearch pfs = new ProhibitedFromSearch( DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, m); ProhibitedFromSearch pfs = new ProhibitedFromSearch( DisplayVocabulary.PRIMARY_SEARCH_INDEX_URI, m);
Assert.assertNotNull(pfs.prohibitedClasses); Assert.assertNotNull(pfs.prohibitedClasses);
Assert.assertEquals(1, pfs.prohibitedClasses.size() ); Assert.assertEquals(1, pfs.prohibitedClasses.size() );
Assert.assertTrue(pfs.isClassProhibitedFromSearch("http://vivoweb.org/ontology/core#NonAcademic")); Assert.assertTrue(pfs.isClassProhibitedFromSearch("http://vivoweb.org/ontology/core#NonAcademic"));

View file

@ -143,7 +143,7 @@
.getAttribute("displayOntModel"); .getAttribute("displayOntModel");
if (displayOntModel != null) { if (displayOntModel != null) {
ProhibitedFromSearch pfs = new ProhibitedFromSearch( ProhibitedFromSearch pfs = new ProhibitedFromSearch(
DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel); DisplayVocabulary.PRIMARY_SEARCH_INDEX_URI, displayOntModel);
if( editConfig != null ) if( editConfig != null )
editConfig.setProhibitedFromSearch(pfs); editConfig.setProhibitedFromSearch(pfs);
} }

View file

@ -24,7 +24,7 @@
<li>Create or load ontologies in OWL format</li> <li>Create or load ontologies in OWL format</li>
<li>Edit instances and relationships</li> <li>Edit instances and relationships</li>
<li>Build a public web site to display your data</li> <li>Build a public web site to display your data</li>
<li>Search your data with Lucene</li> <li>Search your data</li>
</ul> </ul>
</section> <!-- #intro --> </section> <!-- #intro -->