0
我有Lucene的提高,荫努力提高其与(名字)字段匹配指定 特定文件我已经发布的代码Lucene的文档推进
private static Document createDoc(String lucDescription,String primaryk,String specialString){
Document doc = new Document();
doc.add(new Field("lucDescription",lucDescription, Field.Store.NO, Field.Index.TOKENIZED));
doc.add(new Field("primarykey",primaryk,Field.Store.YES,Field.Index.NO));
doc.add(new Field("specialDescription",specialString, Field.Store.NO, Field.Index.UN_TOKENIZED));
doc.setBoost ((float)(0.00001));
if (specialString.equals("chris"))
doc.setBoost ((float)(100000.1));
return doc;
}
的部分问题,这是为什么不加工?
public static String dbSearch(String searchString){
List<String> pkList = new ArrayList<String>();
String conCat="(";
try{
String querystr = searchString;
Query query = new QueryParser("lucDescription", new StandardAnalyzer()).parse(querystr);
IndexSearcher searchIndex = new IndexSearcher("/home/athreya/docsIndexFile");
// Index of the User table--> /home/araghu/aditya/indexFile.
Hits hits = searchIndex.search(query);
System.out.println("Found " + hits.length() + " hits.");
for(int iterator=0;iterator<hits.length();iterator++) {
String primKey=hits.doc(iterator).get("primarykey");
System.out.println(primKey);
pkList.add(primKey);
}
searchIndex.close();
预先感谢您 Athreya
好的,谢谢你的回复 – Greenhorn 2010-05-05 16:35:09
if(specialString.equals(“chris”))doc.setBoost((float)(100000.1)); else doc.setBoost((float)(0.00001));这里 我在这里试图取消提升,如果没有找到文档,并最大化它,如果找到,以便文档的分数,如果发现将是高的 – Greenhorn 2010-05-05 16:37:11
好吧,但上面的代码似乎违反直觉,也许把un-boost放在else语句中。还要看看使用卢克的索引,这会告诉你更多关于得分的信息。 – Mikos 2010-05-05 21:22:18