RE: Re: Need urgent help with Solr spatial search using SpatialRecursivePrefixTreeFieldType

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

RE: Re: Need urgent help with Solr spatial search using SpatialRecursivePrefixTreeFieldType

anushka gupta
Hi,

I want to be able to filter on different cities and also sort the results based on geoproximity. But sorting doesn’t work:

admin_directory_search_geolocation?q=david&fq=({!geofilt+sfield=adminLatLon+pt=33.0198431,-96.6988856+d=80+sort=min(geodist(33.0198431,-96.6988856))})+OR+({!geofilt+sfield=adminLatLon+pt=50.2171726,8.265894+d=80+sort=min(geodist(50.2171726,8.265894))})

Sorting works fine if I add ‘&’ in geofilt condition like : q=david&fq={!geofilt&sfield=adminLatLon&pt=33.0198431,-96.6988856&d=80&sort=geodist(33.0198431,-96.6988856)}

But when I combine the two FQs then sorting doesn’t work.

Please help.


Best regards,
Anushka gupta



From: David Smiley <[hidden email]>
Sent: Friday, September 13, 2019 10:29 PM
To: Anushka Gupta <[hidden email]>
Subject: [EXT]Re: Need urgent help with Solr spatial search using SpatialRecursivePrefixTreeFieldType

Hello,

Please don't email me directly for public help.  CC is okay if you send it to [hidden email]<mailto:[hidden email]> so that the Solr community can benefit from my answer or might even answer it.

~ David Smiley
Apache Lucene/Solr Search Developer
http://www.linkedin.com/in/davidwsmiley<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.linkedin.com_in_davidwsmiley&d=DwMFaQ&c=yIH1_-b1hO27QV_BdDph9suDL0Jq0WcgndLmIuQXoms&r=0egJOuVVdmY5VQTw_S3m4bVez1r-U8nqqi6RYBxO6tTbzryrDHrFoJROJ8r-TqNc&m=ulu2-5V3TDOnVNfRRQusod6-FoJcdeAWu5gGB3owryU&s=Hv2uYeXnut3oi1ijHp14BJ09QIZzhEI-onwzhnQYB8I&e=>


On Wed, Sep 11, 2019 at 11:27 AM Anushka Gupta <[hidden email]<mailto:[hidden email]>> wrote:
Hello David,

I read a lot of articles of yours regarding Solr spatial search using SpatialRecursivePrefixTreeFieldType. But unfortunately it doesn’t work for me when I combine filter query with my keyword search.

Solr Version used : Solr 7.1.0

I have declared fields as :

<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType" geo="true" maxDistErr="0.001"
                                                distErrPct="0.025" distanceUnits="kilometers"/>

<field name="adminLatLon" type="location_rpt" indexed="true" stored="true"  multiValued="true" />


Field values are populated like :
adminLatLon: [50.2171726,8.265894]

Query is :
/solr/ac3_persons/admin_directory_search_location?q=Idstein&q.alt=Idstein&fq={!geofilt%20cache=false%20cost=100}&sfield=adminLatLon&pt=50.2171726,8.265894&d=500&bf=recip(geodist(),2,200,20)&debug=true

My request handler is :
admin_directory_search_location

I get results if I do :
/solr/ac3_persons/admin_directory_search_location?q=*:*&q.alt=Idstein&fq={!geofilt%20cache=false%20cost=100}&sfield=adminLatLon&pt=50.2171726,8.265894&d=500&bf=recip(geodist(),2,200,20)&debug=true

But I do not get results when I add any keyword in q.

I am stuck in this issue since last many days. Could you please help with the same.


Thanks,
Anushka Gupta

+========================================================================+
This email is confidential and may be privileged. If you have received it
in error, please notify us immediately and then delete it. Please do not
copy it, disclose its contents or use it for any purpose.
+========================================================================+

+========================================================================+
This email is confidential and may be privileged. If you have received it
in error, please notify us immediately and then delete it.  Please do not
copy it, disclose its contents or use it for any purpose.
+========================================================================+
Reply | Threaded
Open this post in threaded view
|

Re: Re: Need urgent help with Solr spatial search using SpatialRecursivePrefixTreeFieldType

Tim Casey
https://stackoverflow.com/questions/48348312/solr-7-how-to-do-full-text-search-w-geo-spatial-search


On Mon, Sep 30, 2019 at 10:31 AM Anushka Gupta <
[hidden email]> wrote:

> Hi,
>
> I want to be able to filter on different cities and also sort the results
> based on geoproximity. But sorting doesn’t work:
>
>
> admin_directory_search_geolocation?q=david&fq=({!geofilt+sfield=adminLatLon+pt=33.0198431,-96.6988856+d=80+sort=min(geodist(33.0198431,-96.6988856))})+OR+({!geofilt+sfield=adminLatLon+pt=50.2171726,8.265894+d=80+sort=min(geodist(50.2171726,8.265894))})
>
> Sorting works fine if I add ‘&’ in geofilt condition like :
> q=david&fq={!geofilt&sfield=adminLatLon&pt=33.0198431,-96.6988856&d=80&sort=geodist(33.0198431,-96.6988856)}
>
> But when I combine the two FQs then sorting doesn’t work.
>
> Please help.
>
>
> Best regards,
> Anushka gupta
>
>
>
> From: David Smiley <[hidden email]>
> Sent: Friday, September 13, 2019 10:29 PM
> To: Anushka Gupta <[hidden email]>
> Subject: [EXT]Re: Need urgent help with Solr spatial search using
> SpatialRecursivePrefixTreeFieldType
>
> Hello,
>
> Please don't email me directly for public help.  CC is okay if you send it
> to [hidden email]<mailto:[hidden email]> so
> that the Solr community can benefit from my answer or might even answer it.
>
> ~ David Smiley
> Apache Lucene/Solr Search Developer
> http://www.linkedin.com/in/davidwsmiley<
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.linkedin.com_in_davidwsmiley&d=DwMFaQ&c=yIH1_-b1hO27QV_BdDph9suDL0Jq0WcgndLmIuQXoms&r=0egJOuVVdmY5VQTw_S3m4bVez1r-U8nqqi6RYBxO6tTbzryrDHrFoJROJ8r-TqNc&m=ulu2-5V3TDOnVNfRRQusod6-FoJcdeAWu5gGB3owryU&s=Hv2uYeXnut3oi1ijHp14BJ09QIZzhEI-onwzhnQYB8I&e=
> >
>
>
> On Wed, Sep 11, 2019 at 11:27 AM Anushka Gupta <
> [hidden email]<mailto:
> [hidden email]>> wrote:
> Hello David,
>
> I read a lot of articles of yours regarding Solr spatial search using
> SpatialRecursivePrefixTreeFieldType. But unfortunately it doesn’t work for
> me when I combine filter query with my keyword search.
>
> Solr Version used : Solr 7.1.0
>
> I have declared fields as :
>
> <fieldType name="location_rpt"
> class="solr.SpatialRecursivePrefixTreeFieldType" geo="true"
> maxDistErr="0.001"
>                                                 distErrPct="0.025"
> distanceUnits="kilometers"/>
>
> <field name="adminLatLon" type="location_rpt" indexed="true"
> stored="true"  multiValued="true" />
>
>
> Field values are populated like :
> adminLatLon: [50.2171726,8.265894]
>
> Query is :
>
> /solr/ac3_persons/admin_directory_search_location?q=Idstein&q.alt=Idstein&fq={!geofilt%20cache=false%20cost=100}&sfield=adminLatLon&pt=50.2171726,8.265894&d=500&bf=recip(geodist(),2,200,20)&debug=true
>
> My request handler is :
> admin_directory_search_location
>
> I get results if I do :
>
> /solr/ac3_persons/admin_directory_search_location?q=*:*&q.alt=Idstein&fq={!geofilt%20cache=false%20cost=100}&sfield=adminLatLon&pt=50.2171726,8.265894&d=500&bf=recip(geodist(),2,200,20)&debug=true
>
> But I do not get results when I add any keyword in q.
>
> I am stuck in this issue since last many days. Could you please help with
> the same.
>
>
> Thanks,
> Anushka Gupta
>
> +========================================================================+
> This email is confidential and may be privileged. If you have received it
> in error, please notify us immediately and then delete it. Please do not
> copy it, disclose its contents or use it for any purpose.
> +========================================================================+
>
> +========================================================================+
> This email is confidential and may be privileged. If you have received it
> in error, please notify us immediately and then delete it.  Please do not
> copy it, disclose its contents or use it for any purpose.
> +========================================================================+
>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Need urgent help with Solr spatial search using SpatialRecursivePrefixTreeFieldType

david.w.smiley@gmail.com
In reply to this post by anushka gupta
"sort" is a regular request parameter.  In your non-working query, you
specified it as a local-param inside geofilt which isn't where it belongs.
If you want to sort from two points then you need to make up your mind on
how to combine the distances into some greater aggregate function (e.g.
min/max/sum).

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


On Mon, Sep 30, 2019 at 10:22 AM Anushka Gupta <
[hidden email]> wrote:

> Hi,
>
>
>
> I want to be able to filter on different cities and also sort the results
> based on geoproximity. But sorting doesn’t work:
>
>
>
>
> admin_directory_search_geolocation?q=david&fq=({!geofilt+sfield=adminLatLon+pt=33.0198431,-96.6988856+d=80+sort=min(geodist(33.0198431,-96.6988856))})+OR+({!geofilt+sfield=adminLatLon+pt=50.2171726,8.265894+d=80+sort=min(geodist(50.2171726,8.265894))})
>
>
>
> Sorting works fine if I add ‘&’ in geofilt condition like :
> q=david&fq={!geofilt&sfield=adminLatLon&pt=33.0198431,-96.6988856&d=80&sort=geodist(33.0198431,-96.6988856)}
>
>
>
> But when I combine the two FQs then sorting doesn’t work.
>
>
>
> Please help.
>
>
>
>
>
> Best regards,
>
> Anushka gupta
>
>
>
>
>
>
>
> *From:* David Smiley <[hidden email]>
> *Sent:* Friday, September 13, 2019 10:29 PM
> *To:* Anushka Gupta <[hidden email]>
> *Subject:* [EXT]Re: Need urgent help with Solr spatial search using
> SpatialRecursivePrefixTreeFieldType
>
>
>
> Hello,
>
>
>
> Please don't email me directly for public help.  CC is okay if you send it
> to [hidden email] so that the Solr community can benefit
> from my answer or might even answer it.
>
>
> ~ David Smiley
>
> Apache Lucene/Solr Search Developer
>
> http://www.linkedin.com/in/davidwsmiley
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.linkedin.com_in_davidwsmiley&d=DwMFaQ&c=yIH1_-b1hO27QV_BdDph9suDL0Jq0WcgndLmIuQXoms&r=0egJOuVVdmY5VQTw_S3m4bVez1r-U8nqqi6RYBxO6tTbzryrDHrFoJROJ8r-TqNc&m=ulu2-5V3TDOnVNfRRQusod6-FoJcdeAWu5gGB3owryU&s=Hv2uYeXnut3oi1ijHp14BJ09QIZzhEI-onwzhnQYB8I&e=>
>
>
>
>
>
> On Wed, Sep 11, 2019 at 11:27 AM Anushka Gupta <
> [hidden email]> wrote:
>
> Hello David,
>
>
>
> I read a lot of articles of yours regarding Solr spatial search using
> SpatialRecursivePrefixTreeFieldType. But unfortunately it doesn’t work for
> me when I combine filter query with my keyword search.
>
>
>
> Solr Version used : Solr 7.1.0
>
>
>
> I have declared fields as :
>
>
>
> <fieldType name="location_rpt"
> class="solr.SpatialRecursivePrefixTreeFieldType" geo="true"
> maxDistErr="0.001"
>
>                                                 distErrPct="0.025"
> distanceUnits="kilometers"/>
>
>
>
> <field name="adminLatLon" type="location_rpt" indexed="true"
> stored="true"  multiValued="true" />
>
>
>
>
>
> Field values are populated like :
>
> adminLatLon: [50.2171726,8.265894]
>
>
>
> Query is :
>
>
> /solr/ac3_persons/admin_directory_search_location?q=Idstein&q.alt=Idstein&fq={!geofilt%20cache=false%20cost=100}&sfield=adminLatLon&pt=50.2171726,8.265894&d=500&bf=recip(geodist(),2,200,20)&debug=true
>
>
>
> My request handler is :
>
> admin_directory_search_location
>
>
>
> I get results if I do :
>
> /solr/ac3_persons/admin_directory_search_location?q=*:*
> &q.alt=Idstein&fq={!geofilt%20cache=false%20cost=100}&sfield=adminLatLon&pt=50.2171726,8.265894&d=500&bf=recip(geodist(),2,200,20)&debug=true
>
>
>
> But I do not get results when I add any keyword in q.
>
>
>
> I am stuck in this issue since last many days. Could you please help with
> the same.
>
>
>
>
>
> Thanks,
>
> Anushka Gupta
>
>
>
> +========================================================================+
> This email is confidential and may be privileged. If you have received it
> in error, please notify us immediately and then delete it. Please do not
> copy it, disclose its contents or use it for any purpose.
> +========================================================================+
>
> +========================================================================+
> This email is confidential and may be privileged. If you have received it
> in error, please notify us immediately and then delete it. Please do not
> copy it, disclose its contents or use it for any purpose.
> +========================================================================+
>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Need urgent help with Solr spatial search using SpatialRecursivePrefixTreeFieldType

anushka gupta
Thanks,

Could you please help me in combining two geofilt fqs as the following gives
error, it treats ")" as part of the d parameter and gives error that 'd=80)'
is not a valid param:

({!geofilt}&sfield=adminLatLon&pt=33.0198431,-96.6988856&d=80)+OR+({!geofilt}&sfield=adminLatLon&pt=50.2171726,8.265894&d=80)



--
Sent from: https://lucene.472066.n3.nabble.com/Solr-User-f472068.html
Reply | Threaded
Open this post in threaded view
|

Re: Re: Need urgent help with Solr spatial search using SpatialRecursivePrefixTreeFieldType

david.w.smiley@gmail.com
Do you know how URLs are structured?  They include name=value pairs
separated by ampersands.  This takes precedence over the contents of any
particular name or value.  Consequently looking at your parenthesis doesn't
make sense since the open-close span ampersands and thus go to different
filter queries.  I think you can completely remove those parenthesis in
fact.  Also try a tool like Postman to compose your queries rather than
direct URL manipulation.

&sfield=adminLatLon
&d=80
&fq= {!geofilt pt=33.0198431,-96.6988856} OR {!geofilt
pt=50.2171726,8.265894}

Notice the leading space after 'fq'.  This is a syntax parsing gotcha that
has to do with how embedded queries are parsed, which is what you need to
do as you need to compose two with an operator.  It'd be kinda awkard to
fix that gotcha in Solr.  There are other techniques too, but this is the
most succinct.

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


On Tue, Oct 1, 2019 at 7:34 AM anushka gupta <
[hidden email]> wrote:

> Thanks,
>
> Could you please help me in combining two geofilt fqs as the following
> gives
> error, it treats ")" as part of the d parameter and gives error that
> 'd=80)'
> is not a valid param:
>
>
> ({!geofilt}&sfield=adminLatLon&pt=33.0198431,-96.6988856&d=80)+OR+({!geofilt}&sfield=adminLatLon&pt=50.2171726,8.265894&d=80)
>
>
>
> --
> Sent from: https://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>