You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@nutch.apache.org by frgrfg gfsdgffsd <ki...@yahoo.fr> on 2006/10/11 09:38:13 UTC
Re : Re : Searching terms saved in a file
Thank you very much, now I know where I am going...
Hope I am not bothering you...
So I am still having problems... Should I implements the QueryFilter interface to get this plugin working?
Here is my code:
public class PersoSearch implements QueryFilter{
{
try {
Query query = new Query();
query.addRequiredTerm("foobar");
// Create a Configuration for Nutch. Configuration Provides access to configuration parameters.
Configuration conf = NutchConfiguration.create();
// Path to crawled index folder
Path path = new Path("C:\\cygwin\\nutch-0.8.1\\crawled\\index");
IndexSearcher searcher = new IndexSearcher(path , conf);
NutchBean nutchBean = new NutchBean(conf);
Hits hits = nutchBean.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();
}
}
public BooleanQuery filter(Query input, BooleanQuery translation) throws QueryException {
// TODO Auto-generated method stub
return null;
}
public void setConf(Configuration arg0) {
// TODO Auto-generated method stub
}
public Configuration getConf() {
// TODO Auto-generated method stub
return null;
}
}
But it is stille not working, I have the following messages:
2006-10-11 12:58:06,238 WARN QueryFilters - QueryFilter: PersoSearch names no fields.
2006-10-11 12:59:11,534 INFO NutchBean - query request from 127.0.0.1
**2006-10-11 12:59:11,534 INFO NutchBean - query:
2006-10-11 12:59:11,534 INFO NutchBean - lang: fr
2006-10-11 12:59:11,550 INFO NutchBean - searching for 20 raw hits
**As you can see, the query is empty...
And if it is not asking too much, can you plz explain the concept of "field"? What's the difference between a field and a term?
Thanks a lot again!
----- Message d'origine ----
De : Dennis Kubes <nu...@dragonflymc.com>
À : nutch-user@lucene.apache.org
Envoyé le : Mardi, 10 Octobre 2006, 23h22mn 44s
Objet : Re: Re : Searching terms saved in a file
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();
}
frgrfg gfsdgffsd wrote:
> Thanks a lot Dennis!
> But it is still not that clear to me...
> Have you got any example of how constructing a Query object using the addRequired and addProhibited methods? (I am also beginner in Java...)
> And what doo you mean by "Then pass that into the appropriate NutchBean search method"??
> Any code example?
> Actually my problem is that the Nutch javadoc is not really clear to me, any better documented docs somewhere?
> Thank you very much again!!
> Mat
>
> ----- Message d'origine ----
> De : Dennis Kubes <nu...@dragonflymc.com>
> À : nutch-user@lucene.apache.org
> Envoyé le : Mardi, 10 Octobre 2006, 19h57mn 17s
> Objet : Re: Searching terms saved in a file
>
> You would have to write something that would loop through the file and
> then construct a Query object using the addRequired and addProhibited
> methods to add your terms and phrases. Then pass that into the
> appropriate NutchBean search method to get your results.
>
> Dennis
>
> frgrfg gfsdgffsd wrote:
>
>> Hi all,
>>
>> As a new nutch's user, I am quite stuck regarding this:
>> How can I launch a search using a file containing my terms/keywords instead of typing them in search.jsp??
>> Do I have to use the Query.term class? If yes, How and where do I use this class?
>> Thanks a lot!
>>
>>
>> Mat
>>
>>
>>
>>
>>
>>
>>
>>
>> ___________________________________________________________________________
>> 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
>>
>>
>
>
>
>
>
>
>
>
>
>
>
> ___________________________________________________________________________
> 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
>
___________________________________________________________________________
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