You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Zoomash Team <in...@zoomash.co.uk> on 2016/09/28 16:39:02 UTC

Solr spatial search not returning any results in response element

down votefavorite
<http://stackoverflow.com/questions/39739430/solr-spatial-search-not-returning-any-results-in-response-element#>

I am using Solr version 6.2.1 and trying to return closest location for a
given latitude and longitude.

I have manage to add data into Solr and indexed it.

My data file (.CSV) is in this format:

id,areaname,geo,country,state
1125257,"Mumbai","18.9750,72.8258","India","Maharashtra"
1125258,"Mumgaon","26.3833,93.4833","India","Assam"
1125259,"Mummasar","28.2167,74.2833","India","Rajasthan"
1125260,"Mummidivaram","16.6500,82.1167","India","Andhra Pradesh"
1125261,"Munaba","25.7500,70.2833","India","Rajasthan"
1125262,"Munabao","25.7500,70.2833","India","Rajasthan"
1125263,"Munabo","25.7500,70.2833","India","Rajasthan"
1125264,"Munagala","17.0500,79.8333","India","Andhra Pradesh"

Under managed-schema file following fields are setup:

<fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>

and field geo as:

<field name="geo" type="location" indexed="true" stored="true" />
<field name="geo_0_coordinate" type="tdouble" indexed="true" stored="false" />
<field name="geo_1_coordinate" type="tdouble" indexed="true" stored="false" />

Now when I am running my query to find closest location, it is returning
nothing in response element.

{!geofilt sfield=geo}&pt=28.2167,74.2833&d=100

No error in logs and data is indexed.

Please could someone explain me as to why this is not working.

Thanks.


A

Re: Solr spatial search not returning any results in response element

Posted by Erick Erickson <er...@gmail.com>.
Should be something like:
<add>
<doc>
  <field name="id">1125258</field>
  <field name="areaname">Mumgaon</field>
  <field name="geo">26.3833,93.4833</field>
</doc>

<doc>
  <field name="id">1125259</field>
  <field name="areaname">Mummasar</field>
  <field name="geo">28.2167,74.2833</field>
</doc>

</add>

Then just post it to Solr with post.jar. for testing, just to make
things simple, I put the XML file in example/exampledocs/eoe.xml and
issued the following from that directory.

java -Durl=http://localhost:8983/solr/techproducts/update -jar post.jar eoe.xml

But let me emphasize that it should _not_ be necessary to use the XML
form, the CSV should work if it's set up correctly and be faster.
Furthermore, the post.jar tool isn't always the best choice for
production. I just used these since they were easy for testing on a
stock Solr. If you get it working with the XML import, then you can be
confident that your field definitions are OK etc.  focus on getting
the CSV import to behave....

Best,
Erick


On Wed, Sep 28, 2016 at 10:55 AM, Zoomash Team <in...@zoomash.co.uk> wrote:
> Hi,
>
> Thanks for your reply.
>
> What format should xml file be for data import?
>
> Will something like below be acceptable to my field definition?
>
> <?xml version="1.0" encoding="utf-8" ?>
> <location>
>   <id>1</id>
>   <areaname>Test</areaname>
>   <geo>123,456</geo>
> </location>
>
> <location>
>   <id>2</id>
>   <areaname>Test2</areaname>
>   <geo>78,89</geo>
> </location>
>
>
> Thanks
>
> AA
>
>
> On 28 September 2016 at 18:38, Erick Erickson <er...@gmail.com>
> wrote:
>
>> First, nice job of posting enough information to define the problem and
>> allow
>> us to check something! Far too often it takes 3 back-and-forths to get
>> enough
>> info to say anything.
>>
>> Hmm, on the surface that looks OK. I tried using your field
>> definitions, data and query
>> and it works fine on my machine on 6.2.1.
>>
>> I used this query:
>>
>> http://localhost:8983/solr/techproducts/query?q={!
>> geofilt%20sfield=geo}&pt=28.2167,74.2833&d=100
>>
>> I'm assuming you left off the "q=" bits just for brevity. If I don't
>> put that in I get zero docs...
>>
>> So that makes me wonder if your import is somehow not doing what you
>> expect. Rather
>> than use CSV, I copy/pasted into an XML doc and posted that since it
>> was faster....
>>
>> Try going into the admin UI>>(core)>>schema and picking one of the geo
>> fields
>> (geo_0_coordinate or geo_1_coordinate) You should see some stuff that
>> "makes sense"
>> although there'll also be some extra stuff due to it being a tdouble.
>> This is to check
>> that the import is happening correctly.
>>
>> And if none of that makes sense, could you paste the results of adding
>> &debug=query
>> to the URL?
>>
>>
>> Best,
>> Erick
>>

Re: Solr spatial search not returning any results in response element

Posted by Zoomash Team <in...@zoomash.co.uk>.
Hi,

Thanks for your reply.

What format should xml file be for data import?

Will something like below be acceptable to my field definition?

<?xml version="1.0" encoding="utf-8" ?>
<location>
  <id>1</id>
  <areaname>Test</areaname>
  <geo>123,456</geo>
</location>

<location>
  <id>2</id>
  <areaname>Test2</areaname>
  <geo>78,89</geo>
</location>


Thanks

AA


On 28 September 2016 at 18:38, Erick Erickson <er...@gmail.com>
wrote:

> First, nice job of posting enough information to define the problem and
> allow
> us to check something! Far too often it takes 3 back-and-forths to get
> enough
> info to say anything.
>
> Hmm, on the surface that looks OK. I tried using your field
> definitions, data and query
> and it works fine on my machine on 6.2.1.
>
> I used this query:
>
> http://localhost:8983/solr/techproducts/query?q={!
> geofilt%20sfield=geo}&pt=28.2167,74.2833&d=100
>
> I'm assuming you left off the "q=" bits just for brevity. If I don't
> put that in I get zero docs...
>
> So that makes me wonder if your import is somehow not doing what you
> expect. Rather
> than use CSV, I copy/pasted into an XML doc and posted that since it
> was faster....
>
> Try going into the admin UI>>(core)>>schema and picking one of the geo
> fields
> (geo_0_coordinate or geo_1_coordinate) You should see some stuff that
> "makes sense"
> although there'll also be some extra stuff due to it being a tdouble.
> This is to check
> that the import is happening correctly.
>
> And if none of that makes sense, could you paste the results of adding
> &debug=query
> to the URL?
>
>
> Best,
> Erick
>

Re: Solr spatial search not returning any results in response element

Posted by Erick Erickson <er...@gmail.com>.
First, nice job of posting enough information to define the problem and allow
us to check something! Far too often it takes 3 back-and-forths to get enough
info to say anything.

Hmm, on the surface that looks OK. I tried using your field
definitions, data and query
and it works fine on my machine on 6.2.1.

I used this query:

http://localhost:8983/solr/techproducts/query?q={!geofilt%20sfield=geo}&pt=28.2167,74.2833&d=100

I'm assuming you left off the "q=" bits just for brevity. If I don't
put that in I get zero docs...

So that makes me wonder if your import is somehow not doing what you
expect. Rather
than use CSV, I copy/pasted into an XML doc and posted that since it
was faster....

Try going into the admin UI>>(core)>>schema and picking one of the geo fields
(geo_0_coordinate or geo_1_coordinate) You should see some stuff that
"makes sense"
although there'll also be some extra stuff due to it being a tdouble.
This is to check
that the import is happening correctly.

And if none of that makes sense, could you paste the results of adding
&debug=query
to the URL?


Best,
Erick