Jérôme,

        Thanks for think link you sent earlier.  I've read through that 
discussion and I think my problem must be related, but I'm still banging my 
head against it.  I'm pretty sure that there's something I'm missing about how 
the queries get added together.

        As it stands my query filter seems to modify the ranking, but doesn't 
affect the results returned.  I've pasted my code bellow and I'd appreciate it 
if someone could take a look and let me know if they see the problem.

Thanks,
Jake.

public class MetaQueryFilter implements QueryFilter {

  private static final Logger LOG = LogFormatter
    .getLogger(MetaQueryFilter.class.getName());

  /**
   * Need to pull out the list of meta tags from the configuration
   */
  private static String [] META_TAGS =
                  NutchConf.get().getStrings("meta.names");

  /**
   * We're going to go through and create search filters for each of the 
meta-tags we were asked to index.
   */
  public BooleanQuery filter(Query input, BooleanQuery output) {
                  // If no meta-tags were specified in the conf file, then 
don't bother wasting cycles
                  if ( META_TAGS.equals(null) ) {
                                  return output;
                  }

                  addTerms(input, output);
                  return output;
  }

  private static void addTerms(Query input, BooleanQuery output) {
                  Clause[] clauses = input.getClauses();
                  for (int x = 0; x < clauses.length; x++) {
                                  Clause c = clauses[x];
                                  if 
(!c.getField().equals(Clause.DEFAULT_FIELD))
                                          continue;             // skip 
non-default fields

                                  // These are the fields we're interested in 
indexing
                                  String [] tagsToIndex = META_TAGS;

                                  for (int i = 0; i < tagsToIndex.length; ++i) {
                                                  LOG.info("Meta Query Filter: 
Adding a search for " + tagsToIndex[i]);

                                                  Term term = new 
Term(tagsToIndex[i], c.getTerm().toString());

                                                  // add a lucene PhraseQuery 
for this tag
                                                  PhraseQuery metaQuery = new 
PhraseQuery();
                                                  metaQuery.setSlop(0);
                                                  metaQuery.add(term);

                                                  // set boost
                                                  metaQuery.setBoost(2.0f);

                                                  // add it as a specified query
                                                  output.add(metaQuery, false, 
false);
                                  }
                  }
  }

}

Reply via email to