diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculateBeta.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculateBeta.java new file mode 100644 index 000000000..46772ecf0 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculateBeta.java @@ -0,0 +1,25 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.search.solr; + +import org.apache.solr.common.SolrInputDocument; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; + +public class CalculateBeta implements DocumentModifier{ + + @Override + public void modifyDocument(Individual individual, SolrInputDocument doc) { + // TODO Auto-generated method stub + + /* + may want to do something like: + + Field f = doc.getField(termALLTEXTUSTEMMED); + f.setBoost( beta * f.getBoost() ) + + + */ + } + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculatePhi.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculatePhi.java new file mode 100644 index 000000000..57c01dda1 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculatePhi.java @@ -0,0 +1,16 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.search.solr; + +import org.apache.solr.common.SolrInputDocument; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; + +public class CalculatePhi implements DocumentModifier{ + + @Override + public void modifyDocument(Individual individual, SolrInputDocument doc) { + // TODO Auto-generated method stub + } + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ContextNodeFields.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ContextNodeFields.java new file mode 100644 index 000000000..0a06fe7db --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ContextNodeFields.java @@ -0,0 +1,16 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.search.solr; + +import org.apache.solr.common.SolrInputDocument; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; + +public class ContextNodeFields implements DocumentModifier{ + + @Override + public void modifyDocument(Individual individual, SolrInputDocument doc) { + // TODO Auto-generated method stub + } + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/DocumentModifier.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/DocumentModifier.java new file mode 100644 index 000000000..662c017ec --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/DocumentModifier.java @@ -0,0 +1,14 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.search.solr; + +import org.apache.solr.common.SolrInputDocument; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; + +/** + * This interface represents an object that can add to a SolrInputDocument. + */ +public interface DocumentModifier { + public void modifyDocument(Individual individual, SolrInputDocument doc); +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/IndividualToSolrDocument.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/IndividualToSolrDocument.java index d33ea1fe8..e607e3b75 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/IndividualToSolrDocument.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/IndividualToSolrDocument.java @@ -52,6 +52,8 @@ public class IndividualToSolrDocument implements Obj2DocIface { private IndividualProhibitedFromSearch individualProhibitedFromSearch; private SearchQueryHandler searchQueryHandler; + + private List documentModifiers = new ArrayList(); public static Map betas = new Hashtable(); @@ -66,7 +68,15 @@ public class IndividualToSolrDocument implements Obj2DocIface { fillContextNodes(); } - + public IndividualToSolrDocument(ProhibitedFromSearch classesProhibitedFromSearch, + IndividualProhibitedFromSearch individualProhibitedFromSearch, + List docModifiers){ + this.classesProhibitedFromSearch = classesProhibitedFromSearch; + this.individualProhibitedFromSearch = individualProhibitedFromSearch; + this.documentModifiers = docModifiers; + fillContextNodes(); + } + @SuppressWarnings("static-access") @Override public Object translate(Object obj) throws IndexingException{ @@ -317,6 +327,13 @@ public class IndividualToSolrDocument implements Obj2DocIface { doc.addField(term.ALLTEXTUNSTEMMED, alltext, 2.5F*beta*phi); doc.addField(term.ALLTEXT_PHONETIC, alltext, PHONETIC_BOOST); doc.setDocumentBoost(2.5F*beta*phi); + + //run the document modifiers + if( documentModifiers != null ){ + for(DocumentModifier modifier: documentModifiers){ + modifier.modifyDocument(ent, doc); + } + } } return doc;