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 mapbutcher <ma...@mapbutcher.com> on 2011/01/24 10:46:49 UTC

Indexing spatial columns

Hi,

I'm a bit of a solr beginner. I have installed Solr 4.0 and I'm trying to
index some spatial data stored in a sql server instance. I'm using the
DataImportHandler here is my data-comfig.xml:

<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost\sqlserver08;databaseName=Spatial" user="sa"
password="sqlserver08"/>
  <document>
    <entity name="poi" query="select OBJECTID,CATEGORY,NAME,POINT_X,POINT_Y
from NZ_POI">
		<field column="OBJECTID" name="id"/>
		<field column="CATEGORY" name="category"/>
		<field column="NAME" name="name"/>
		<field column="POINT_X" name="lat"/>
		<field column="POINT_Y" name="lon"/>
	</entity>
  </document>
</dataConfig>

In my schema file I have following definition:

   <field name="category" type="string" indexed="true" stored="true"/>
   <field name="name" type="string" indexed="true" stored="true"/>
   <field name="lat" type="tdouble" indexed="true" stored="true"/>   
   <field name="lon" type="tdouble" indexed="true" stored="true"/>

   <copyField source="category" dest="text"/>
   <copyField source="name" dest="text"/>

I have completed a data import with no errors in the log as far as i can
tell. However when i inspect the schema i do not see the columns names
lat\lon. When sending the query:

http://localhost:8080/Solr/select/?q=Camp AND _val_:"recip(dist(2, lon, lat,
44.794, -93.2696), 1, 1, 0)"^100 

I get an error undefined column. 

Does anybody have any ideas about whether the above is the correct procedure
for indexing spatial data?

Cheers

S


-- 
View this message in context: http://lucene.472066.n3.nabble.com/Indexing-spatial-columns-tp2318493p2318493.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Indexing spatial columns

Posted by Adam Estrada <es...@gmail.com>.
Hi MapButcher,

There are a couple things that are going on here. 

1. The spatial functionality is confusing between versions of Solr. I wish someone would update the solr Spatial Search wiki page. 
2.  You will want to use the jTDS Driver here instead of the one from Microsoft. http://jtds.sourceforge.net/ It works a little better.
3.  For Solr 4.0 you will basically have to concatenate the lat/long fields in to a single column which in the example schema is called "store"
4. I don't know if individual columns actually exist for latitude and longitude in 4.0 but in 1.4.x I know the lat/long type HAD to be called lat and lng and had to be tdouble type which I see below.
5. Revert back to Solr 1.4.x and try using their plugin http://www.jteam.nl/news/spatialsolr.html
6. Try your queries in the Solr admin tool first before trying to integrate this in to your code.

Overall, I have had great success with Solr Spatial in just doing a simple radius search. I am using the core 4.0 functionality and am having no problems. I will eventually get in to distance and bounding box queries do ehstever you figure out and share would be great!

Good luck,
Adam

On Jan 24, 2011, at 4:46 AM, mapbutcher wrote:

> 
> Hi,
> 
> I'm a bit of a solr beginner. I have installed Solr 4.0 and I'm trying to
> index some spatial data stored in a sql server instance. I'm using the
> DataImportHandler here is my data-comfig.xml:
> 
> <dataConfig>
> <dataSource type="JdbcDataSource"
> driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
> url="jdbc:sqlserver://localhost\sqlserver08;databaseName=Spatial" user="sa"
> password="sqlserver08"/>
>  <document>
>    <entity name="poi" query="select OBJECTID,CATEGORY,NAME,POINT_X,POINT_Y
> from NZ_POI">
> 		<field column="OBJECTID" name="id"/>
> 		<field column="CATEGORY" name="category"/>
> 		<field column="NAME" name="name"/>
> 		<field column="POINT_X" name="lat"/>
> 		<field column="POINT_Y" name="lon"/>
> 	</entity>
>  </document>
> </dataConfig>
> 
> In my schema file I have following definition:
> 
>   <field name="category" type="string" indexed="true" stored="true"/>
>   <field name="name" type="string" indexed="true" stored="true"/>
>   <field name="lat" type="tdouble" indexed="true" stored="true"/>   
>   <field name="lon" type="tdouble" indexed="true" stored="true"/>
> 
>   <copyField source="category" dest="text"/>
>   <copyField source="name" dest="text"/>
> 
> I have completed a data import with no errors in the log as far as i can
> tell. However when i inspect the schema i do not see the columns names
> lat\lon. When sending the query:
> 
> http://localhost:8080/Solr/select/?q=Camp AND _val_:"recip(dist(2, lon, lat,
> 44.794, -93.2696), 1, 1, 0)"^100 
> 
> I get an error undefined column. 
> 
> Does anybody have any ideas about whether the above is the correct procedure
> for indexing spatial data?
> 
> Cheers
> 
> S
> 
> 
> -- 
> View this message in context: http://lucene.472066.n3.nabble.com/Indexing-spatial-columns-tp2318493p2318493.html
> Sent from the Solr - User mailing list archive at Nabble.com.