Adding field NAMERAW to lucene index.

This commit is contained in:
bdc34 2011-02-03 18:44:21 +00:00
parent f510462ad2
commit dbf3391541
5 changed files with 15 additions and 11 deletions

View file

@ -185,7 +185,7 @@ public class EntityListController extends VitroHttpServlet {
try{
docs = index.search(query, null,
ENTITY_LIST_CONTROLLER_MAX_RESULTS,
new Sort(Entity2LuceneDoc.term.NAMEUNANALYZED));
new Sort(Entity2LuceneDoc.term.NAMELOWERCASE));
}catch(Throwable th){
log.error("Could not run search. " + th.getMessage());
docs = null;
@ -271,7 +271,7 @@ public class EntityListController extends VitroHttpServlet {
Query alphaQuery = null;
if( alpha != null && !"".equals(alpha) && alpha.length() == 1){
alphaQuery =
new PrefixQuery(new Term(Entity2LuceneDoc.term.NAMEUNANALYZED, alpha.toLowerCase()));
new PrefixQuery(new Term(Entity2LuceneDoc.term.NAMELOWERCASE, alpha.toLowerCase()));
query.add(alphaQuery,BooleanClause.Occur.MUST);
}

View file

@ -105,7 +105,7 @@ public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOExc
IndexSearcher index = LuceneIndexFactory.getIndexSearcher(getServletContext());
TopDocs docs = index.search(query, null,
ENTITY_LIST_CONTROLLER_MAX_RESULTS,
new Sort(Entity2LuceneDoc.term.NAMEUNANALYZED));
new Sort(Entity2LuceneDoc.term.NAMELOWERCASE));
if( docs == null ){
log.error("Search of lucene index returned null");

View file

@ -247,10 +247,10 @@ public void doGet( HttpServletRequest req, HttpServletResponse response )
}else if( sortField.equalsIgnoreCase("sunset") ){
sort = new Sort(Entity2LuceneDoc.term.SUNSET);
}else{
sort = new Sort(Entity2LuceneDoc.term.NAMEUNANALYZED);
sort = new Sort(Entity2LuceneDoc.term.NAMELOWERCASE);
}
} else {
sort = new Sort(Entity2LuceneDoc.term.NAMEUNANALYZED);
sort = new Sort(Entity2LuceneDoc.term.NAMELOWERCASE);
}
if( depth > 1 && "rand()".equalsIgnoreCase(sortField) ){
@ -482,7 +482,7 @@ public void doGet( HttpServletRequest req, HttpServletResponse response )
Query alphaQuery = null;
if( alpha != null && !"".equals(alpha) && alpha.length() == 1){
alphaQuery =
new PrefixQuery(new Term(Entity2LuceneDoc.term.NAMEUNANALYZED, alpha.toLowerCase()));
new PrefixQuery(new Term(Entity2LuceneDoc.term.NAMELOWERCASE, alpha.toLowerCase()));
query.add(alphaQuery,BooleanClause.Occur.MUST);
}

View file

@ -329,7 +329,7 @@ public class AutocompleteController extends FreemarkerHttpServlet{
private Query makeUntokenizedNameQuery(String querystr) {
querystr = querystr.toLowerCase();
String termName = Entity2LuceneDoc.term.NAMEUNANALYZED;
String termName = Entity2LuceneDoc.term.NAMELOWERCASE;
BooleanQuery query = new BooleanQuery();
log.debug("Adding wildcard query on unanalyzed name");
query.add(

View file

@ -47,9 +47,11 @@ public class Entity2LuceneDoc implements Obj2DocIface{
/** Name of entity, tab or vclass */
public static String NAME = "name";
/** rdfs:label unanalyzed */
public static String NAMEUNANALYZED = "nameunanalyzed" ;
public static String NAMELOWERCASE = "nameunanalyzed" ;
/** Name of entity, unstemmed */
public static String NAMEUNSTEMMED = "nameunstemmed";
/** Unaltered name of individual, un-lowercased, un-stemmed, un-tokenized" */
public static String NAMERAW = "nameraw";
/** portal ( 2 ^ portalId ) */
public static String PORTAL = "portal";
/** Flag 2 (legacy, only used at Cornell) */
@ -122,7 +124,7 @@ public class Entity2LuceneDoc implements Obj2DocIface{
value = ent.getLocalName();
}
Field name =new Field(term.NAME, value,
Field.Store.YES, Field.Index.ANALYZED);
Field.Store.NO, Field.Index.ANALYZED);
name.setBoost( NAME_BOOST );
doc.add( name );
@ -131,10 +133,12 @@ public class Entity2LuceneDoc implements Obj2DocIface{
nameUn.setBoost( NAME_BOOST );
doc.add( nameUn );
Field nameUnanalyzed = new Field(term.NAMEUNANALYZED, value.toLowerCase(),
Field nameUnanalyzed = new Field(term.NAMELOWERCASE, value.toLowerCase(),
Field.Store.YES, Field.Index.NOT_ANALYZED);
doc.add( nameUnanalyzed );
doc.add( new Field(term.NAMERAW, value, Field.Store.YES, Field.Index.NOT_ANALYZED));
//boost for entity
if( ent.getSearchBoost() != null && ent.getSearchBoost() != 0 )
doc.setBoost(ent.getSearchBoost());