-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: IllegalArgumentException for filter taking parameters
PostPosted: Wed Feb 25, 2009 1:11 pm 
Beginner
Beginner

Joined: Tue Feb 03, 2009 12:29 pm
Posts: 49
hi,

My Hibernate search version is 3.1. I'm getting IllegalArgumentException (the exception stack trace at the bottom) while building the FullTextQuery if I pass parameters to the filter as shown.
Code:
FullTextFilter filter = hibQuery.enableFullTextFilter(filterName);
filter.setParameter("latitude", 100);

If I comment out the line passing parameters to the filter, there is no error.

My filter class is here, it has a setter method and property for 'latitude'.
Code:
public class DistanceFilter extends org.apache.lucene.search.Filter {

   private Double latitude, longitude;

   private Double lowerLimit, upperLimit;

   public Double getLatitude() {
      return latitude;
   }

   public void setLatitude(Double latitude) {
      this.latitude = latitude;
   }

   
    @Key
    public FilterKey getKey() {
        StandardFilterKey key = new StandardFilterKey();
        key.addParameter( lowerLimit );
        key.addParameter( upperLimit );
        key.addParameter( latitude );
        key.addParameter( longitude );
        return key;
    }

   public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
      OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());

      TermDocs td = reader.termDocs();
      TermEnum termEnum = reader.terms();
      while (termEnum.next()) {
         String fieldName = termEnum.term().field();
         if (fieldName.equals("longitude")) {
            System.out.println("val is " + termEnum.term().text());
            td.seek(termEnum.term());
            if (td.next()) {
               int doc = td.doc();
               bitSet.set(doc);
               Document document = reader.document(doc);
               System.out.println("Longitude is "
                     + document.get("longitude"));
               Double distance = DistanceCalculation.getInstance()
                     .distanceCalculator(latitude, longitude,
                           getLatitude(), getLongitude());
               System.out.println("Distance is " + distance);
            }
         }
      }

   return bitSet;
   }


   public Double getLongitude() {
      return longitude;
   }

   public void setLongitude(Double longitude) {
      this.longitude = longitude;
   }

   public Double getLowerLimit() {
      return lowerLimit;
   }

   public void setLowerLimit(Double lowerLimit) {
      this.lowerLimit = lowerLimit;
   }

   public Double getUpperLimit() {
      return upperLimit;
   }

   public void setUpperLimit(Double upperLimit) {
      this.upperLimit = upperLimit;
   }


Quote:

Caused by: java.lang.IllegalArgumentException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at org.hibernate.search.engine.FilterDef.invoke(FilterDef.java:70)
at org.hibernate.search.query.FullTextQueryImpl.createFilterInstance(FullTextQueryImpl.java:553)
at org.hibernate.search.query.FullTextQueryImpl.buildLuceneFilter(FullTextQueryImpl.java:408)
at org.hibernate.search.query.FullTextQueryImpl.buildFilters(FullTextQueryImpl.java:381)
at org.hibernate.search.query.FullTextQueryImpl.getQueryHits(FullTextQueryImpl.java:348)
at org.hibernate.search.query.FullTextQueryImpl.getResultSize(FullTextQueryImpl.java:741)
at org.hibernate.search.jpa.impl.FullTextQueryImpl.getResultSize(FullTextQueryImpl.java:64)
at com.adesa.data.framework.dao.jpa.SearchIndexDaoImpl$2.doInJpa(SearchIndexDaoImpl.java:176)
at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:185)
... 46 more


Thanks,
Seema


Top
 Profile  
 
 Post subject: Solved...was a silly mistake
PostPosted: Thu Feb 26, 2009 4:02 am 
Beginner
Beginner

Joined: Tue Feb 03, 2009 12:29 pm
Posts: 49
hi,

That was a stupid mistake on my part, nothing to do with Hibernate search. I passed a wrong data type for the filter parameter.

Thanks,
Seema


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.