DSE:地理位置,即纬度和经度在 cassandra 中存储为不同的字段

DSE: Geo location i.e latitude and longitude is stored as different fields in cassandra

我正在从 Apache Cassandra 升级到 Datastax Cassandra。计划在我的 table 之一上使用位置搜索功能。

当前 table 看起来像下面

CREATE TABLE tweets (
   id INT PRIMARY KEY,
   user TEXT,
   body TEXT,
   time TIMESTAMP,
   latitude FLOAT,
   longitude FLOAT
);

在示例 Datastax Solr config 中,我看到纬度和经度应该属于同一列。有什么方法可以索引 纬度和经度分开,以便 Solr 可以理解?

For Spatial Queries in solr you need to store latitude and longitude comma separated in the field having type location.

if you try to put only single value in field type location it will gives you error, if you want use solr's Spatial search then you have to store both as comma separated in location type only.

You can store both values in different field using data type either pfloat or pdouble, but you can not use solr's Spatial search functionality for finding nearest distance.

我认为您可以通过使用 Field Input Transformer (FIT) 来实现这一点 - 它允许转换提交给 Solr 的文档,因此您可以获取两个坐标并从中创建一个字段。请检查链接的文档 - 它有示例代码,应该不会很难实现。

P.S。您可以查看 RPT (RecursivePrefixTree) instead - it could be more efficient. I also have an example 如何在 DSE 中配置此字段类型,而不是 LatLong 类型(尽管我在 DSE 核心中使用 DSE 的 PointType)。