当前位置:  开发笔记 > 前端 > 正文

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

如何解决《使用多值位置字段在solr中搜索》经验,为你挑选了1个好方法。

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



1> geerlingguy..:

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

您可以将以下内容添加到schema.xml:


然后将该location_rpt字段用于多值坐标字段,并从Solr 4的新空间搜索提供的所有优势中受益.

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

推荐阅读
k78283381
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有