Dear all,

I tried to use SynonymsQuery mentioned at:
http://mail-archives.apache.org/mod_mbox/lucene-java-user/200603.mbox/[EMAIL 
PROTECTED]

Compiling the given source code results in error message:
"The method createWeight(Searcher) in the type Query is not applicable for
the arguments  (Searcher) " in:

public SynonymsWeight( Searcher searcher ) throws IOException {
     this.searcher = searcher;
     weights = new Weight[queries.size()];
     for( int i = 0; i < queries.size(); i++ )
error here ===>        weights[i] = ((QueryInfo) queries.get
(i)).getQuery().createWeight(searcher);
       squareWeights = new float[queries.size()];
   }


I tried to fix it by changing the line with error to: weights[i] =
((SynonymsQuery) ((QueryInfo) queries.get
(i)).getQuery()).createWeight(searcher);

Then I tried it out in :
               Term t1 = new Term("content", "fraudulent");
       Query query1 = new TermQuery(t1);

       Term t2 = new Term("content", "deceptive");
       Query query2 = new TermQuery(t2);

          SynonymsQuery q= new SynonymsQuery();
          q.add(query1,1.0f,false);
          q.add(query2,0.8f,true);

       Hits hits = searcher.search(q);

The error is:
Exception in thread "main" java.lang.UnsupportedOperationException
   at org.apache.lucene.search.Query.createWeight(Query.java:87)
   at org.apache.lucene.search.Query.weight(Query.java:94)
   at org.apache.lucene.search.Hits.<init>(Hits.java:41)
   at org.apache.lucene.search.Searcher.search(Searcher.java:44)
   at org.apache.lucene.search.Searcher.search(Searcher.java:36)
   at SynonymQuerySample.main(SynonymQuerySample.java:31)

Please tell me what I am doing wrong here.....

Thanks a lot.

Ng Vinny

Reply via email to