Solr空间搜索使用索引字段进行半径? [英] Solr spatial search using an indexed field for radius?
问题描述
所以我有一个城市的索引,看起来像这样:
{
location: 41.388587,2.175888,
name:BARCELONA,
radius:20
}
我们有几十个。我需要能够使用一个单一的lat / lng组合查询该索引,并查看它是否落入我们的城市之一。
位置
属性是城市的中心,而半径
是以km为单位的城市半径(假设所有城市都是圆形)。我们也可以假定没有任何城市重叠。
如何将一个拉丁/联盟组合置于城市之内? > 例如,给定点$ code> 40.419691,-3.701254 ,如何判断是否属于BARCELONA? 您可以轻松地在Lucene,Solr或ES中执行。 在Solr中,例如: ,您可以为每个城市创建一个特定的圈子,然后在一个称为形状的字段,例如: 然后您只需查询与您的点相交的任何文档(未测试): 确保检查您正在使用的特定版本的Lucene / Solr / ES的文档和javadoc,因为API已在此空间中更改 So I have an index of cities, looks something like this: We have a few dozen of these. I need to be able to query this index with a single lat/lng combination and see if it falls inside one of our "cities". The How can I return whether or not a lat/lng combination falls within a city? For example, given the point you can do it easily, in either Lucene, Solr or ES. In Solr for example: by using lat/long and the radius, you create an specific circle for each city, and you index that shape, in a field called 'shape' for example: then you just query for any doc that intersects with your point (untested): Be sure to check the docs and javadocs for the specific version of Lucene/Solr/ES you are using, as APIs have been changing in this space 这篇关于Solr空间搜索使用索引字段进行半径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
{
location:41.388587,2.175888,
name:BARCELONA,
shape:CIRCLE(2.175888 41.388587,20)
}
fq = shape:相交(40.419691 -3.701254)
{
"location": "41.388587, 2.175888",
"name": "BARCELONA",
"radius": 20
}
location
property is the centre of the city, and the radius
is the radius of the city in km (assuming all the cities are circles). We can also assume no cities overlap.40.419691, -3.701254
, how can I determine if this falls within BARCELONA?
{
"location": "41.388587, 2.175888",
"name": "BARCELONA",
"shape": "CIRCLE (2.175888 41.388587, 20)"
}
fq=shape:"Intersects(40.419691 -3.701254)"