我可以为solr中的位置类型字段索引多个值。修改后的schema.xml
和索引修改的exampledocs的响应如下所示
查询:
http://192.168.3.19:8983/solr/select?wt=json&indent=true&q=*:*
回应:
{
"id":"TWINX2048-3200PRO",
"name":"CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail",
"manu":"Corsair Microsystems Inc.",
"price":185.0,
"popularity":5,
"inStock":true,
"manufacturedate_dt":"2006-02-13T15:26:37Z",
"payloads":"electronics|6.0 memory|3.0",
"cat":["electronics","memory"],
"store":["37.7752,-122.4232","37.7752,-122.4232","38.7752,-122.4232","39.7752,-122.4232"],
"features":[
"CAS latency 2,\t2-3-3-6 timing, 2.75v, unbuffered, heat-spreader"]},
{
"id":"VS1GB400C3",
"name":"CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail",
"manu":"Corsair Microsystems Inc.",
"price":74.99,
"popularity":7,
"inStock":true,
"manufacturedate_dt":"2006-02-13T15:26:37Z",
"payloads":"electronics|4.0 memory|2.0",
"cat":["electronics","memory"],
"store":["37.7752,-100.0232","37.7752,-122.4232","38.7752,-122.4232","39.7752,-122.4232"]},
{
"id":"VDBDB1A16",
"name":"A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM",
"manu":"A-DATA Technology Inc.",
"popularity":0,
"inStock":true,
"manufacturedate_dt":"2006-02-13T15:26:37Z",
"payloads":"electronics|0.9 memory|0.1",
"cat":["electronics","memory"],
"store":["45.17614,-93.87341","37.7752,-122.4232","38.7752,-122.4232","39.7752,-122.4232"],
"features":[
"CAS latency 3,\t 2.7v"]},
{
女巫意味着数据存储正确。 如果我查询第一个存储的地理位置它工作正常,但如果我搜索第三或第四个地理定位solr返回没有结果。 如果我运行以下查询:
http://localhost:8983/solr/select?wt=json&indent=true&q=*:*&fq={!geofilt%20pt=45.17614,-93.87341%20sfield=store%20d=5}
我得到了正确答案:
{ "id":"VDBDB1A16", "name":"A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM", "manu":"A-DATA Technology Inc.", "popularity":0, "inStock":true, "manufacturedate_dt":"2006-02-13T15:26:37Z", "payloads":"electronics|0.9 memory|0.1", "cat":["electronics","memory"], "store":["45.17614,-93.87341","37.7752,-122.4232","38.7752,-122.4232","39.7752,-122.4232"], "features":[ "CAS latency 3,\t 2.7v"]}, { But if the query is: http://localhost:8983/solr/select?wt=json&indent=true&q=*:*&fq={!geofilt%20pt=38.7752,-122.4232%20sfield=store%20d=50}
我不会得到任何结果。 这是solr问题吗?任何解决方案?
答案 0 :(得分:5)
旧问题,但它仍然存在于许多Google搜索结果中,因此这里有更多关于多值坐标字段的信息:
您可以将以下内容添加到schema.xml中:
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
distErrPct="0.025"
maxDistErr="0.000009"
units="degrees" />
然后将location_rpt
字段用于多值坐标字段,并享受Solr 4's new spatial search提供的所有优势。
如果使用自定义spatialContextFactory,还需要将JTS jar添加到solr类路径。如果从fieldType
定义中删除该参数,则多值字段仍然有效,但其他高级功能则不会。
答案 1 :(得分:1)
根据vuky在d whelan的回答中提到的票证(SOLR-2154),这应该是在所有新的Solr版本中。这是由机票SOLR-3304(https://issues.apache.org/jira/browse/SOLR-3304)确定的,该票已于2012年9月17日标记为已修复。
我无法真正找到它应该起作用的特定版本,但我想如果我阅读了门票中的评论,那么2013年5月之后发布的所有内容都应该有效。
答案 2 :(得分:0)
LatLon类型不能多值。