下午好,
我想要做的是对数据进行空间搜索,该数据存储在我的Cassandra数据库中并使用DataStax Enterprise连接到Solr .
一些信息....我已经创建了数据库并存储了数据..我也已经创建了一个solr核心,我可以使用Solr Admin在我的数据库中查询数据 .
此时,我正在改变schema.xml的步骤,以便可以读取我的数据并执行空间查询 .
我有几个问题,
1)我应该在Cassandra中使用哪种变量类型,以便能够通过cassandra正确读取我的纬度和经度点?
这就是我现在所拥有的 - 一个输入示例 -
- 我的latlng(经度纬度点)在cassandra中存储为varchar变量 .
insert into pois(id, latlng) VALUES('test','45.17614,-93.87341');
- 运行时仍然会得到相同的结果:
"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)这是我当前的schema.xml ----看起来对你来说是否正确?
*不确定我是否在正确的地方有动态字段.....(也在字段部分尝试过)
这是我在solr admin中使用的查询....也在终端上试过
{!geofilt pt=45.15,-93.85 sfield=geopoint d=5}
----关于管理员
SELECT * FROM pois WHERE solr_query='{!geofilt sfield=geopoint pt=45.15,-93.85 d=5}' limit 10;
-----在终端上
这就是我创建表格的方式:
CREATE TABLE pois(id text,latlng varchar,PRIMARY KEY(id));
我数据库中的数据:
cqlsh:geo> select * from pois;
id | geopoint | mylocation | solr_query -------- --------------------- -------------------- - ------------首页| 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 |空值
我的密钥空间是这样的:
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>
谢谢!
1 回答
查看Github上的Patrick Calahan's demo,了解如何执行此操作的示例(包括xml)
Patrick使用text varchar作为latlong字段,但看起来两者都支持datastax docs .
你在字段部分中的方式看起来是正确的 . 你能仔细检查你在这里发布的xml和cql与你正在运行的内容吗?您还没有定义名为mylocation的字段,但这是错误消息中的字段名称,它确实出现在select *的cqlsh输出中 . 您的问题可能与此有关 .
在查询中,您正在使用名为geopoint的字段,该字段不在您的cql定义或错误消息中 . 我现在很困惑 . 你能回去用匹配的信息更新你的问题吗?