Lucene документ Boosting - PullRequest
0 голосов
/ 05 мая 2010

У меня проблема с повышением lucene, Iam пытается повысить конкретный документ, который соответствует указанному полю (имя) Я разместил часть кода

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

1 Ответ

1 голос
/ 05 мая 2010

Трудно сказать, что может быть не так, просто взглянув на код, попробую пару вещей:

  1. открыть индекс с помощью Люка и посмотреть счет для документа (содержащего "Крис")
  2. Не уверен, что вы обходите один или другой вызов setboost.

    if (specialString.equals ("chris")) doc.setBoost ((float) (100000.1)); еще doc.setBoost ((float) (0.00001));

...