THANKS A LOT! At last I got something working, the thing is that I wanted to make it to complicated I think...
Thanks again, hope I will be able to help one day... cheers ----- Message d'origine ---- De : Dennis Kubes <[EMAIL PROTECTED]> À : [email protected] Envoyé le : Mardi, 17 Octobre 2006, 21h47mn 13s Objet : Re: Extending BasicQueryFilter for a new plugiin? I don't know exactly what you are wanting to do below. Adding a term through a query filter would be something like this: import org.apache.nutch.searcher.FieldQueryFilter; import org.apache.hadoop.conf.Configuration; public class NewQueryFilter extends FieldQueryFilter { public CategoryQueryFilter() { super("term"); } public void setConf(Configuration conf) { super.setConf(conf); } } Searching would be in its own code usually being called through a servlet or jsp page. The reason eclipse isn't happy is because the code below needs to be inside of a method like so: public class Search { public static void main(String[] args) { Query query = new Query(); query.addRequiredTerm("term"); Configuration conf = NutchConfiguration.create(); IndexSearcher searcher = new IndexSearcher(new Path("C:\\path\\to\\index"), conf); NutchBean bean = new NutchBean(conf); Hits hits = bean.search(query, 10); HitDetails[] details = searcher.getDetails(hits.getHits(0,hits.getLength())); for (int i = 0; i < details.length; i++) { HitDetails curDetail = details[i]; System.out.println(curDetail); } } } Dennis frgrfg gfsdgffsd wrote: > Hi Dennis, > > Sorry to disturb you again but I reaaly cannot get this code working... > should I put the code you gave me in a classe extending BasicQueryFilter? > > Here is my code in its simplest form: > > public class Search extends BasicQueryFilter{ > > {try{ > Query query = new Query(); > query.addRequiredTerm("term"); > > Configuration conf = NutchConfiguration.create(); > IndexSearcher searcher = new IndexSearcher(new > Path("C:\\path\\to\\index"), conf); > > NutchBean bean = new NutchBean(conf); > Hits hits = bean.search(query, 10); > HitDetails[] details = > searcher.getDetails(hits.getHits(0,hits.getLength())); > > for (int i = 0; i < details.length; i++) { > HitDetails curDetail = details[i]; > System.out.println(curDetail); > > } > } > catch (IOException e) { > e.printStackTrace(); > } > }} > > Still, eclipse is not happy, asking to add a { before the try, > why???........... > HELP! :D > > Hope > you can help me solving this problem... > > Thanks a lot > --------------------------------------------------------------------------------------------------------------------------- > > Try something like this. The conf folder holding the nutch-site.xml and > hadoop-site.xml file must be in the classpath here. I have the file > system set to local and I have an index on the local filesystem. > > Dennis > > try { > > Scanner scanner = new Scanner(new File("C:\\d01\\searchterms.txt")); > Query query = new Query(); > while (scanner.hasNext()) { > query.addRequiredTerm(scanner.nextLine().trim()); > } > > Configuration conf = > NutchConfiguration.create(); > IndexSearcher searcher = new IndexSearcher(new > Path("C:\\d01\\crawl3\\index"), conf); > NutchBean bean = new NutchBean(conf); > Hits hits = bean.search(query, 10); > HitDetails[] details = searcher.getDetails(hits.getHits(0, > hits.getLength())); > > for (int i = 0; i < details.length; i++) { > HitDetails curDetail = details[i]; > System.out.println(curDetail); > } > } > catch (IOException e) { > e.printStackTrace(); > } > > > > > Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! > Demandez à ceux qui savent sur Yahoo! Questions/Réponses. > > > > > > > > > > ___________________________________________________________________________ > Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! > Demandez à ceux qui savent sur Yahoo! Questions/Réponses > http://fr.answers.yahoo.com > ___________________________________________________________________________ Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire. http://fr.mail.yahoo.com
