【发布时间】:2015-03-15 10:32:20
【问题描述】:
下午好,
我要做的是对存储在我的 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 ---- 你觉得它正确吗?
*不确定我是否在正确的位置放置了dynamicField.....(也在字段部分尝试过)
这是我在 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> 从 pois 中选择 * ;
标识 |地理点 |我的位置 | solr_query --------+---------------------+-------- --+------------ 主页 | 45.17614,-93.87341 | 45.17614,-93.87341 |空值 家常| 146.17614,-89.87341 | 146.17614,-89.87341 |空值 本垒打| 46.17614,-91.87341 | 46.17614,-91.87341 |空
我的键空间是这样制作的:
使用 REPLICATION = {'class':'NetworkTopologyStrategy', 'Solr':1} 创建 KEYSPACE geo;
<?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>
谢谢!
【问题讨论】:
标签: solr cassandra geospatial datastax-enterprise datastax