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
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Nutch-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nutch-general