繁体   English   中英

使用多值位置字段在solr中搜索

[英]Search in solr with multivalued location field

我可以为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问题吗? 有解决方案吗

老问题,但它仍然存在于许多谷歌搜索结果中,所以这里有更多关于多值坐标字段的信息:

您可以将以下内容添加到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的新空间搜索提供的所有优势中受益。

如果使用自定义spatialContextFactory,还需要将JTS jar添加到solr类路径。 如果从fieldType定义中删除该参数,则多值字段仍然有效,但其他高级功能则不然。

根据vuky在d whelan的回答中提到的票证(SOLR-2154),这应该是在所有新的Solr版本中。 这是通过机票SOLR-3304( https://issues.apache.org/jira/browse/SOLR-3304 )修复的,该机票已于2012年9月17日标记为已修复。

我无法真正找到它应该起作用的特定版本,但我想如果我阅读门票中的注释,2013年5月之后发布的所有内容都应该有效。

LatLon类型不能是多值的。

http://wiki.apache.org/solr/SpatialSearch#LatLonType

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM