Hi all, I developed a couple of plugins to add and search a custom field.
The indexing plugin works fine (with Luke I can see the field is added to
the index). But when it comes to search no documents are returned...

Here the plugins code:

----------------- Indexing plugin ---------------------------

package org.apache.nutch.indexer.quiew;

import ...;

public class QuiewIndexingFilter implements IndexingFilter {

  public Document filter(Document doc, Parse parse, FetcherOutput fo)
    throws IndexingException {

    String url = fo.getUrl().toString();
    doc.add(new Field("quiewId", MD5Hash.digest(url).toString(), true, true,
false));

    return doc;
  }

}

---------------- Query plugin ----------------------
package org.apache.nutch.searcher.quiew;

import org.apache.nutch.searcher.FieldQueryFilter;

public class QuiewQueryFilter extends FieldQueryFilter {

    public QuiewQueryFilter() {
        super("quiewId");
    }
}

And here's how I try to perform the query:

String query = "quiewId:a3d32ce0cae0da47677f30cc6182d421";
NutchBean bean = new NutchBean(new File(indexPath));
Query q = Query.parse(query);
Hits hits = bean.search(q, 1000);
long tot = hits.getTotal();

System.out.println("Query returned " + tot + " hits.");

for(int i = 0; i < tot; i++) {

   Hit hit = hits.getHit(i);
   HitDetails details = bean.getDetails(hit);

   System.out.println("Resource title: " + details.getValue("title"));
   System.out.println("Resource url: " + details.getValue("url"));
}

If I perform the same query with Luke, I get correct results, but only if I
use the KeywordAnalyzer...

What am I doing wrong?

Thanks,
Enrico

Reply via email to