added dismax query parser, boost for alltext fields and changed name of ContextNodeFactory
This commit is contained in:
parent
51bb061156
commit
cf69ec009a
9 changed files with 68 additions and 38 deletions
|
@ -498,7 +498,7 @@
|
|||
<field name="THUMBNAIL" type="string" indexed="true" stored="true"/>
|
||||
|
||||
<field name="contextNode" type="text" indexed="true" stored="true" multiValued="true"/>
|
||||
|
||||
<field name="BETA" type="float" indexed="true" stored="true" multiValued="false"/>
|
||||
|
||||
<field name="moniker" type="ignored" />
|
||||
<field name="modType" type="ignored"/>
|
||||
|
@ -573,7 +573,7 @@
|
|||
<uniqueKey>DocId</uniqueKey>
|
||||
|
||||
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
|
||||
<defaultSearchField>ALLTEXT</defaultSearchField>
|
||||
<!-- <defaultSearchField>ALLTEXT</defaultSearchField> -->
|
||||
|
||||
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
|
||||
<solrQueryParser defaultOperator="AND"/>
|
||||
|
|
|
@ -707,6 +707,8 @@
|
|||
will be overridden by parameters in the request
|
||||
-->
|
||||
<lst name="defaults">
|
||||
<str name="defType">dismax</str>
|
||||
<str name="qf">nameRaw nameLowercase nameUnstemmed nameStemmed ALLTEXT ALLTEXTUNSTEMMED</str>
|
||||
<str name="echoParams">explicit</str>
|
||||
<int name="rows">10</int>
|
||||
</lst>
|
||||
|
@ -784,10 +786,12 @@
|
|||
<str name="v.layout">layout</str>
|
||||
<str name="title">Solritas</str>
|
||||
|
||||
<str name="defType">edismax</str>
|
||||
<!-- <str name="defType">edismax</str> -->
|
||||
|
||||
<str name="q.alt">*:*</str>
|
||||
<str name="rows">10</str>
|
||||
<str name="fl">*,score</str>
|
||||
|
||||
<str name="mlt.qf">
|
||||
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
|
||||
</str>
|
||||
|
|
|
@ -54,4 +54,7 @@ public class VitroTermNames {
|
|||
|
||||
/** rdfs:label lowercased, tokenized, stop words, stemmed **/
|
||||
public static String NAME_STEMMED = "nameStemmed"; // was NAME
|
||||
|
||||
/** field for beta values of all documents **/
|
||||
public static final String BETA = "BETA";
|
||||
}
|
||||
|
|
|
@ -15,15 +15,17 @@ import com.hp.hpl.jena.query.QuerySolutionMap;
|
|||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.query.Syntax;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
|
||||
public class ContextNodesInclusionFactory {
|
||||
public class SearchQueryHandler {
|
||||
|
||||
private OntModel fullModel;
|
||||
private String contextNodeURI;
|
||||
|
@ -32,9 +34,9 @@ public class ContextNodesInclusionFactory {
|
|||
// private static final String queryForEducationalTraining = "SELECT ?query WHERE {" +
|
||||
// "?searchConfig <"+ DisplayVocabulary.QUERY_FOR_EDUCATIONAL_TRAINING + "> ?query . }";
|
||||
|
||||
private static Log log = LogFactory.getLog(ContextNodesInclusionFactory.class);
|
||||
private static Log log = LogFactory.getLog(SearchQueryHandler.class);
|
||||
|
||||
public ContextNodesInclusionFactory(String contextNodeURI,
|
||||
public SearchQueryHandler(String contextNodeURI,
|
||||
OntModel displayOntModel, ServletContext context) {
|
||||
this.fullModel = ModelContext.getJenaOntModel(context);
|
||||
this.contextNodeURI = contextNodeURI;
|
||||
|
@ -643,6 +645,22 @@ public class ContextNodesInclusionFactory {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private int getTotalIndividuals(){
|
||||
return fullModel.listIndividuals().toList().size();
|
||||
}
|
||||
|
||||
public float calculateBeta(String uri){
|
||||
float beta=0;
|
||||
RDFNode node = (Resource) fullModel.getResource(uri);
|
||||
StmtIterator stmtItr = fullModel.listStatements((Resource)null, (Property)null,node);
|
||||
int Conn = 0;
|
||||
while(stmtItr.hasNext()){
|
||||
stmtItr.next();
|
||||
Conn++;
|
||||
}
|
||||
|
||||
beta = (float)Conn/getTotalIndividuals();
|
||||
beta += 1;
|
||||
return beta;
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ 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.ContextNodesInclusionFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.SearchQueryHandler;
|
||||
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;
|
||||
|
@ -110,7 +110,7 @@ public class Entity2LuceneDoc implements Obj2DocIface{
|
|||
|
||||
private IndividualProhibitedFromSearch individualProhibited;
|
||||
|
||||
private ContextNodesInclusionFactory contextNodesInclusionFactory;
|
||||
private SearchQueryHandler searchQueryHandler;
|
||||
|
||||
private static HashMap<String, String> IndividualURIToObjectProperties = new HashMap<String, String>();
|
||||
|
||||
|
@ -118,10 +118,10 @@ public class Entity2LuceneDoc implements Obj2DocIface{
|
|||
|
||||
public Entity2LuceneDoc(
|
||||
ProhibitedFromSearch classesProhibitedFromSearch,
|
||||
IndividualProhibitedFromSearch individualProhibited, ContextNodesInclusionFactory contextNodesInclusionFactory){
|
||||
IndividualProhibitedFromSearch individualProhibited, SearchQueryHandler searchQueryHandler){
|
||||
this.classesProhibitedFromSearch = classesProhibitedFromSearch;
|
||||
this.individualProhibited = individualProhibited;
|
||||
this.contextNodesInclusionFactory = contextNodesInclusionFactory;
|
||||
this.searchQueryHandler = searchQueryHandler;
|
||||
}
|
||||
|
||||
public boolean canTranslate(Object obj) {
|
||||
|
@ -242,12 +242,12 @@ public class Entity2LuceneDoc implements Obj2DocIface{
|
|||
String contextNodePropertyValues;
|
||||
|
||||
// if(ent.isVClass("http://xmlns.com/foaf/0.1/Person")){
|
||||
contextNodePropertyValues = contextNodesInclusionFactory.getPropertiesAssociatedWithEducationalTraining(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithRole(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithPosition(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithRelationship(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithAwardReceipt(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithInformationResource(ent.getURI());
|
||||
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());
|
||||
|
||||
// }
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.SearchReindexingListener;
|
|||
import edu.cornell.mannlib.vitro.webapp.search.beans.IndividualProhibitedFromSearch;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ObjectSourceIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ContextNodesInclusionFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.SearchQueryHandler;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.AbortStartup;
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class LuceneSetup implements javax.servlet.ServletContextListener {
|
|||
Entity2LuceneDoc translator = new Entity2LuceneDoc(
|
||||
new ProhibitedFromSearch(DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel),
|
||||
new IndividualProhibitedFromSearch(context),
|
||||
new ContextNodesInclusionFactory(DisplayVocabulary.CONTEXT_NODES_URI, displayOntModel, context)
|
||||
new SearchQueryHandler(DisplayVocabulary.CONTEXT_NODES_URI, displayOntModel, context)
|
||||
|
||||
);
|
||||
indexer.addObj2Doc(translator);
|
||||
|
|
|
@ -27,7 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SearchReindexingListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ContextNodesInclusionFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.SearchQueryHandler;
|
||||
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.indexing.IndexBuilder;
|
||||
|
@ -94,7 +94,7 @@ public class LuceneSetupCJK implements javax.servlet.ServletContextListener {
|
|||
Entity2LuceneDoc translator = new Entity2LuceneDoc(
|
||||
new ProhibitedFromSearch(DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel),
|
||||
new IndividualProhibitedFromSearch(context),
|
||||
new ContextNodesInclusionFactory(DisplayVocabulary.CONTEXT_NODES_URI, displayOntModel, context));
|
||||
new SearchQueryHandler(DisplayVocabulary.CONTEXT_NODES_URI, displayOntModel, context));
|
||||
indexer.addObj2Doc(translator);
|
||||
|
||||
indexer.setLuceneIndexFactory(lif);
|
||||
|
|
|
@ -13,6 +13,10 @@ import org.apache.solr.common.SolrDocument;
|
|||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
|
@ -23,7 +27,7 @@ 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.VitroTermNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ContextNodesInclusionFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.SearchQueryHandler;
|
||||
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;
|
||||
|
@ -42,16 +46,16 @@ public class IndividualToSolrDocument implements Obj2DocIface {
|
|||
|
||||
private IndividualProhibitedFromSearch individualProhibitedFromSearch;
|
||||
|
||||
private ContextNodesInclusionFactory contextNodesInclusionFactory;
|
||||
private SearchQueryHandler searchQueryHandler;
|
||||
|
||||
|
||||
|
||||
public IndividualToSolrDocument(ProhibitedFromSearch classesProhibitedFromSearch,
|
||||
IndividualProhibitedFromSearch individualProhibitedFromSearch,
|
||||
ContextNodesInclusionFactory contextNodesInclusionFactory){
|
||||
SearchQueryHandler searchQueryHandler){
|
||||
this.classesProhibitedFromSearch = classesProhibitedFromSearch;
|
||||
this.individualProhibitedFromSearch = individualProhibitedFromSearch;
|
||||
this.contextNodesInclusionFactory = contextNodesInclusionFactory;
|
||||
this.searchQueryHandler = searchQueryHandler;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
|
@ -156,12 +160,12 @@ public class IndividualToSolrDocument implements Obj2DocIface {
|
|||
long tContextNodes = System.currentTimeMillis();
|
||||
|
||||
String contextNodePropertyValues = "";
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithEducationalTraining(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithRole(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithPosition(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithRelationship(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithAwardReceipt(ent.getURI());
|
||||
contextNodePropertyValues += contextNodesInclusionFactory.getPropertiesAssociatedWithInformationResource(ent.getURI());
|
||||
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());
|
||||
|
||||
|
||||
doc.addField(term.CONTEXTNODE, contextNodePropertyValues);
|
||||
|
@ -237,8 +241,8 @@ public class IndividualToSolrDocument implements Obj2DocIface {
|
|||
|
||||
log.debug("time to include data property statements, object property statements in the index: " + Long.toString(System.currentTimeMillis() - tPropertyStatements));
|
||||
|
||||
doc.addField(term.ALLTEXT, value);
|
||||
doc.addField(term.ALLTEXTUNSTEMMED, value);
|
||||
doc.addField(term.ALLTEXT, value,ALL_TEXT_BOOST);
|
||||
doc.addField(term.ALLTEXTUNSTEMMED, value,ALL_TEXT_BOOST);
|
||||
}
|
||||
|
||||
return doc;
|
||||
|
@ -282,5 +286,6 @@ public class IndividualToSolrDocument implements Obj2DocIface {
|
|||
}
|
||||
|
||||
public static float NAME_BOOST = 3.0F;
|
||||
public static float ALL_TEXT_BOOST = 2.0F;
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SearchReindexingListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ContextNodesInclusionFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.SearchQueryHandler;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.IndividualProhibitedFromSearch;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ObjectSourceIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||
|
@ -76,7 +76,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
|
|||
IndividualToSolrDocument indToSolrDoc = new IndividualToSolrDocument(
|
||||
new ProhibitedFromSearch(DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel),
|
||||
new IndividualProhibitedFromSearch(context),
|
||||
new ContextNodesInclusionFactory(DisplayVocabulary.CONTEXT_NODES_URI, displayOntModel, context));
|
||||
new SearchQueryHandler(DisplayVocabulary.CONTEXT_NODES_URI, displayOntModel, context));
|
||||
List<Obj2DocIface> o2d = new ArrayList<Obj2DocIface>();
|
||||
o2d.add(indToSolrDoc);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue