This commit is contained in:
anupsawant 2011-05-25 21:43:32 +00:00
parent ecca050bbc
commit 7d14c52c12
7 changed files with 30 additions and 16 deletions

View file

@ -381,7 +381,7 @@
<fieldtype name="phonetic" stored="false" indexed="true" class="solr.TextField" > <fieldtype name="phonetic" stored="false" indexed="true" class="solr.TextField" >
<analyzer> <analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/> <tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.DoubleMetaphoneFilterFactory" inject="false"/> <filter class="solr.PhoneticFilterFactory" encoder="Metaphone" inject="false"/>
</analyzer> </analyzer>
</fieldtype> </fieldtype>
@ -493,9 +493,11 @@
<field name="acNameUnstemmed" type="textUnstemmed" indexed="true" stored="false" multiValued="true"/> <field name="acNameUnstemmed" type="textUnstemmed" indexed="true" stored="false" multiValued="true"/>
<field name="acNameStemmed" type="text" indexed="true" stored="false" multiValued="true"/> <field name="acNameStemmed" type="text" indexed="true" stored="false" multiValued="true"/>
<field name="indexedTime" type="string" indexed="true" stored="true" multiValued="true"/> <field name="indexedTime" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="NAME_PHONETIC" type ="phonetic" indexed="true" stored="false" multiValued="true"/>
<field name="ALLTEXT" type="text" indexed="true" stored="false" multiValued="true"/> <field name="ALLTEXT" type="text" indexed="true" stored="false" multiValued="true"/>
<field name="ALLTEXTUNSTEMMED" type="textgen" indexed="true" stored="false" multiValued="true"/> <field name="ALLTEXTUNSTEMMED" type="textgen" indexed="true" stored="false" multiValued="true"/>
<field name="ALLTEXT_PHONETIC" type="phonetic" indexed="true" stored="false" multiValued="true"/>
<field name="THUMBNAIL" type="string" indexed="true" stored="true"/> <field name="THUMBNAIL" type="string" indexed="true" stored="true"/>
@ -577,7 +579,7 @@
<uniqueKey>DocId</uniqueKey> <uniqueKey>DocId</uniqueKey>
<!-- field for the QueryParser to use when an explicit fieldname is absent --> <!-- field for the QueryParser to use when an explicit fieldname is absent -->
<!-- <defaultSearchField>ALLTEXT</defaultSearchField> --> <defaultSearchField>ALLTEXT</defaultSearchField>
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" --> <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="AND"/> <solrQueryParser defaultOperator="AND"/>
@ -600,7 +602,8 @@
<!-- Similarity is the scoring routine for each document vs. a query. <!-- Similarity is the scoring routine for each document vs. a query.
A custom similarity may be specified here, but the default is fine A custom similarity may be specified here, but the default is fine
for most applications. --> for most applications. -->
<!-- <similarity class="org.apache.lucene.search.DefaultSimilarity"/> --> <similarity class="org.apache.lucene.search.DefaultSimilarity"/>
<!-- <similarity class="edu.cornell.mannlib.vitro.webapp.search.lucene.CustomSimilarity"/> -->
<!-- ... OR ... <!-- ... OR ...
Specify a SimilarityFactory class name implementation Specify a SimilarityFactory class name implementation
allowing parameters to be used. allowing parameters to be used.

View file

@ -708,8 +708,9 @@
--> -->
<lst name="defaults"> <lst name="defaults">
<str name="defType">dismax</str> <str name="defType">dismax</str>
<str name="qf">nameRaw nameLowercase nameUnstemmed nameStemmed ALLTEXT ALLTEXTUNSTEMMED</str> <str name="qf">nameRaw nameLowercase nameUnstemmed nameStemmed ALLTEXT ALLTEXTUNSTEMMED ALLTEXT_PHONETIC NAME_PHONETIC</str>
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<str name="bf">BETA</str>
<int name="rows">10</int> <int name="rows">10</int>
</lst> </lst>
<!-- In addition to defaults, "appends" params can be specified <!-- In addition to defaults, "appends" params can be specified

View file

@ -57,4 +57,8 @@ public class VitroTermNames {
/** field for beta values of all documents **/ /** field for beta values of all documents **/
public static final String BETA = "BETA"; public static final String BETA = "BETA";
/** adding phonetic field **/
public static final String ALLTEXT_PHONETIC = "ALLTEXT_PHONETIC";
public static final String NAME_PHONETIC = "NAME_PHONETIC";
} }

View file

@ -658,6 +658,7 @@ public class SearchQueryHandler {
} }
beta = (float)Conn/totalInd; beta = (float)Conn/totalInd;
beta *= 100;
beta += 1; beta += 1;
return beta; return beta;
} }

View file

@ -177,6 +177,7 @@ public class SolrPagedSearchController extends FreemarkerHttpServlet {
SolrQuery query = getQuery(qtxt, maxHitCount, vreq); SolrQuery query = getQuery(qtxt, maxHitCount, vreq);
SolrServer solr = SolrSetup.getSolrServer(getServletContext()); SolrServer solr = SolrSetup.getSolrServer(getServletContext());
QueryResponse response = null; QueryResponse response = null;
try { try {
response = solr.query(query); response = solr.query(query);

View file

@ -71,9 +71,9 @@ public class IndividualToSolrDocument implements Obj2DocIface {
String classPublicNames = ""; String classPublicNames = "";
SolrInputDocument doc = new SolrInputDocument(); SolrInputDocument doc = new SolrInputDocument();
//float beta = searchQueryHandler.calculateBeta(ent.getURI()); float beta = searchQueryHandler.calculateBeta(ent.getURI());
//doc.addField(term.BETA,beta); doc.addField(term.BETA,beta);
float beta =1; //float beta =1;
//DocId //DocId
String id = ent.getURI(); String id = ent.getURI();
@ -156,10 +156,11 @@ public class IndividualToSolrDocument implements Obj2DocIface {
value = ent.getLocalName(); value = ent.getLocalName();
} }
doc.addField(term.NAME_RAW, value, (NAME_BOOST*beta)); doc.addField(term.NAME_RAW, value, NAME_BOOST+beta);
doc.addField(term.NAME_LOWERCASE, value.toLowerCase(),(NAME_BOOST*beta)); doc.addField(term.NAME_LOWERCASE, value.toLowerCase(),NAME_BOOST+beta);
doc.addField(term.NAME_UNSTEMMED, value,(NAME_BOOST*beta)); doc.addField(term.NAME_UNSTEMMED, value,NAME_BOOST+beta);
doc.addField(term.NAME_STEMMED, value, (NAME_BOOST*beta)); doc.addField(term.NAME_STEMMED, value, NAME_BOOST+beta);
doc.addField(term.NAME_PHONETIC, value, PHONETIC_BOOST);
long tContextNodes = System.currentTimeMillis(); long tContextNodes = System.currentTimeMillis();
@ -245,8 +246,10 @@ public class IndividualToSolrDocument implements Obj2DocIface {
log.debug("time to include data property statements, object property statements in the index: " + Long.toString(System.currentTimeMillis() - tPropertyStatements)); log.debug("time to include data property statements, object property statements in the index: " + Long.toString(System.currentTimeMillis() - tPropertyStatements));
doc.addField(term.ALLTEXT, value,(ALL_TEXT_BOOST*beta)); doc.addField(term.ALLTEXT, value, 4*beta);
doc.addField(term.ALLTEXTUNSTEMMED, value,(ALL_TEXT_BOOST*beta)); doc.addField(term.ALLTEXTUNSTEMMED, value, 4*beta);
doc.addField(term.ALLTEXT_PHONETIC, value, PHONETIC_BOOST);
doc.setDocumentBoost(2*beta);
} }
return doc; return doc;
@ -289,7 +292,8 @@ public class IndividualToSolrDocument implements Obj2DocIface {
return ent; return ent;
} }
public static float NAME_BOOST = 3.0F; public static float NAME_BOOST = 2.0F;
public static float ALL_TEXT_BOOST = 2.0F; public static float PHONETIC_BOOST = 0.1F;
} }

View file

@ -36,7 +36,6 @@ public class SolrIndexer implements IndexerIface {
@Override @Override
public synchronized void index(Individual ind, boolean newDoc) throws IndexingException { public synchronized void index(Individual ind, boolean newDoc) throws IndexingException {
if( ! indexing ) if( ! indexing )
throw new IndexingException("SolrIndexer: must call " + throw new IndexingException("SolrIndexer: must call " +
"startIndexing() before index()."); "startIndexing() before index().");
@ -61,6 +60,7 @@ public class SolrIndexer implements IndexerIface {
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>(); Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
docs.add( solrDoc ); docs.add( solrDoc );
server.add( docs ); server.add( docs );
// if( !newDoc ){ // if( !newDoc ){
// server.add( docs ); // server.add( docs );
// log.debug("updated " + ind.getName() + " " + ind.getURI()); // log.debug("updated " + ind.getName() + " " + ind.getURI());