Syntax error while parsing Spatial Query as string

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax error while parsing Spatial Query as string

vas aj
Hi team, 

I am using Lucene 6.6.2, Spatial4j 0.7, lucene-spatial-extras 6.6.2. I am trying to create a Spatial Query string for a given longitude, latitude & radius in miles. 

The query string generated using SpatialHelper (code as attached ) for long: -122.8515139 & lat: 45.5099231 in .25 miles radius  is as follow : 

#(+location__x:[-122.85667708964212 TO -122.84635071035788] +location__y:[45.50630481040378 TO 45.51354138959622]) #frange(DistanceValueSource(PointVectorStrategy field:location ctx=SpatialContext.GEO, Pt(x=-122.8515139,y=45.5099231))):[0.0 TO 0.00361828959621958]

My lucene index is as follows:
create lucene index --name=myLuceneIndex --region=stations --field=title --analyzer=org.apache.lucene.analysis.en.EnglishAnalyzer

I get error
Syntax Error, cannot parse ConstantScore(#(+location__x:[-122.85667708964212 TO -122.84635071035788] +location__y:[45.50630481040378 TO 45.51354138959622]) #frange(DistanceValueSource(PointVectorStrategy field:location ctx=SpatialContext.GEO, Pt(x=-122.8515139,y=45.5099231))):[0.0 TO 0.00361828959621958]): 

What am I doing wrong ?

Regards,
Aj

SpatialHelper.java (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Syntax error while parsing Spatial Query as string

david.w.smiley@gmail.com
You are asking on solr-user but your scenario seems pure Lucene.

For Lucene and indexing point-data, I strongly recommend LatLonPoint.  For
Solr, same scenario, the Solr adaptation of the same functionality is
LatLonPointSpatialField.  I know this doesn't directly address your
question.  Just looking at your email and reported error, it seems you are
supplying some custom syntax.  If you wish to proceed with the
SpatialStrategy/Spatial4j based framework, then see SpatialExample.java in
the tests which serve as documentation by example.  FYI PointVectorStrategy
is slated for removal in 9.0 as it's obsolete.

~ David Smiley
Apache Lucene/Solr Search Developer
http://www.linkedin.com/in/davidwsmiley


On Fri, Feb 14, 2020 at 6:47 AM vas aj <[hidden email]> wrote:

> Hi team,
>
> I am using Lucene 6.6.2, Spatial4j 0.7, lucene-spatial-extras 6.6.2. I am
> trying to create a Spatial Query string for a given longitude, latitude &
> radius in miles.
>
> The query string generated using SpatialHelper (code as attached ) for
> long: -122.8515139 & lat: 45.5099231 in .25 miles radius  is as follow :
>
> #(+location__x:[-122.85667708964212 TO -122.84635071035788]
> +location__y:[45.50630481040378 TO 45.51354138959622])
> #frange(DistanceValueSource(PointVectorStrategy field:location
> ctx=SpatialContext.GEO, Pt(x=-122.8515139,y=45.5099231))):[0.0 TO
> 0.00361828959621958]
>
> My lucene index is as follows:
> create lucene index --name=myLuceneIndex --region=stations --field=title
> --analyzer=org.apache.lucene.analysis.en.EnglishAnalyzer
>
> I get error
> Syntax Error, cannot parse
> ConstantScore(#(+location__x:[-122.85667708964212 TO -122.84635071035788]
> +location__y:[45.50630481040378 TO 45.51354138959622])
> #frange(DistanceValueSource(PointVectorStrategy field:location
> ctx=SpatialContext.GEO, Pt(x=-122.8515139,y=45.5099231))):[0.0 TO
> 0.00361828959621958]):
>
> What am I doing wrong ?
>
> Regards,
> Aj
>