2
votes

Good afternoon,

What I am trying to do is a spatial search on data which is stored within my Cassandra database and connected to Solr utilizing the DataStax Enterprise.

Some information.... I already have the database created and stored with data.. I have also already created a solr core and I can query data within my database using the Solr Admin.

At this point, I am at the step of altering my schema.xml so that my data can be read and spatial queries can be performed.

I have a few questions,

1) What variable type should I be using within Cassandra in order to be able to have my latitude and longitude points read correctly by cassandra?

This is what I have now -- an example input --

-- my latlng (longitude latitude points) is stored as a varchar variable in cassandra.

insert into pois(id, latlng) VALUES('test','45.17614,-93.87341');

--still getting the same result when running:

"error": {
    "msg": "The field mylocation does not support spatial filtering",
    "trace": "org.apache.solr.common.SolrException: The field mylocation does not support spatial filtering
    "code": 500

}

2) Here is my current schema.xml ---- does it look correct to you?

*Not sure if I have dynamicField in the right place..... (tried in fields section too)

This is the query I'm using in solr admin.... also tried on terminal

{!geofilt pt=45.15,-93.85 sfield=geopoint d=5} ---- on admin

SELECT * FROM pois WHERE solr_query='{!geofilt sfield=geopoint pt=45.15,-93.85 d=5}' limit 10; ----- on terminal

This is how I created my table:

CREATE TABLE pois (id text, latlng varchar, PRIMARY KEY(id));

Data in my database:

cqlsh:geo> select * from pois ;

id | geopoint | mylocation | solr_query --------+---------------------+---------------------+------------ home | 45.17614,-93.87341 | 45.17614,-93.87341 | null homery | 146.17614,-89.87341 | 146.17614,-89.87341 | null homer | 46.17614,-91.87341 | 46.17614,-91.87341 | null

My keyspace was made like this:

CREATE KEYSPACE geo WITH REPLICATION = {'class':'NetworkTopologyStrategy', 'Solr':1};

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schema name="autoSolrSchema" version="1.5">
    <types>
        <fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
        <fieldType class="solr.LatLonType" subFieldSuffix="_coordinate"     name="coord"/>
    </types>
    <fields>
        <field indexed="true" multiValued="false" name="id" stored="true" type="StrField"/>
        <field indexed="true" multiValued="false" name="latlng" stored="true" type="coord"/>
        <dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false"/>
    </fields>
    <uniqueKey>id</uniqueKey>
</schema>

Thanks!

1

1 Answers

0
votes

Check out Patrick Calahan's demo on Github for an example on how to do this (xml's included)

1) What variable type should I be using within Cassandra in order to be able to have my latitude and longitude points read correctly by cassandra?

Patrick uses text not varchar for the latlong field but it looks like both are supported per the datastax docs.

2) Here is my current schema.xml ---- does it look correct to you?

*Not sure if I have dynamicField in the right place..... (tried in fields section too)

The way you have it in the fields section looks correct. Can you double check the xml and cql you posted here vs what you are running? You have not defined a field called mylocation but that is the field name in the error message and it does appear in your cqlsh output from select *. Your issue is probably related to this.

3) Queries

In the queries you're using a field called geopoint that isn't in your cql definition or in your error message. I'm pretty confused now. Can you go back and update your question with matching info?