lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kumaran <kums....@gmail.com>
Subject problem in using distanceFilter in booleanFilter (using FilterClause)
Date Thu, 10 Apr 2014 05:50:15 GMT
Hi All,

i am trying to add Termfilter and DistanceFilter in BooleanFilter using
FilterClause. But i am getting the below mentioned error. Please check my
code and guide me.


*Code:*

> DistanceQueryBuilder queryBuilder = new DistanceQueryBuilder(latLong[0],
> latLong[1], radius, "lat", "lon", CartesianTierPlotter.DEFALT_FIELD_PREFIX,
> true);
>         DistanceFieldComparatorSource distComp = new
> DistanceFieldComparatorSource(queryBuilder.getDistanceFilter());
>         Sort distSort = new Sort(new SortField("", distComp,true));
>         QueryParser parser = new QueryParser(Version.LUCENE_30, "city",
> new StandardAnalyzer(Version.LUCENE_30));
>         Query query = parser.parse(strQuery);
>         System.out.println(" distance sort details ::: "+ distSort);
>         BooleanFilter boolFilter = new BooleanFilter();
>         FilterClause filterClause2 = new
> FilterClause(queryBuilder.getFilter(), BooleanClause.Occur.MUST);
>         boolFilter.add(filterClause2);
>
>         Term term = new Term("city", "chengalpat");
>         TermsFilter filter = new TermsFilter();
>         filter.addTerm(term);
>         FilterClause filterClause = new FilterClause(filter,
> BooleanClause.Occur.SHOULD);
>         boolFilter.add(filterClause);
>
>         TopDocs topDocs = searcher.search(query,boolFilter, 20,distSort);



*ErrorTrace:*

java.lang.NullPointerException at
> org.apache.lucene.spatial.tier.DistanceFieldComparatorSource$DistanceScoreDocLookupComparator.copy(DistanceFieldComparatorSource.java:105)
> at
> org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.collect(TopFieldCollector.java:89)
> at
> org.apache.lucene.search.IndexSearcher.searchWithFilter(IndexSearcher.java:258)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:218) at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:199) at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:177) at
> org.apache.lucene.search.Searcher.search(Searcher.java:49) at
> com.zoho.training.RadialSearch.search(RadialSearch.java:246) at
> com.zoho.training.RadialSearch.main(RadialSearch.java:281) Exception in
> thread "main" java.lang.NullPointerException at
> org.apache.lucene.spatial.tier.DistanceFieldComparatorSource$DistanceScoreDocLookupComparator.copy(DistanceFieldComparatorSource.java:105)
> at
> org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.collect(TopFieldCollector.java:89)
> at
> org.apache.lucene.search.IndexSearcher.searchWithFilter(IndexSearcher.java:258)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:218) at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:199) at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:177) at
> org.apache.lucene.search.Searcher.search(Searcher.java:49) at
> com.zoho.training.RadialSearch.search(RadialSearch.java:246) at
> com.zoho.training.RadialSearch.main(RadialSearch.java:281)


Kumaran R

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message