简体   繁体   English

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

[英]Search in solr with multivalued location field

I can index multiple values for location type field in solr. 我可以为solr中的位置类型字段索引多个值。 The response for a modified schema.xml and indexing modified exampledocs looks like the query: 修改后的schema.xml和索引修改后的exampledocs的响应类似于查询:

  http://192.168.3.19:8983/solr/select?wt=json&indent=true&q=*:*

The response: 响应:

{
    "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"]},
  {

witch means the data are stored correctly. 巫婆意味着数据存储正确。 If I query for the first stored geolocation it works fine, but if I search for third or fourth geolocation solr returns no result. 如果我查询第一个存储的地理位置它工作正常,但如果我搜索第三或第四个地理定位solr返回没有结果。 If I run the following query: 如果我运行以下查询:

http://localhost:8983/solr/select?wt=json&indent=true&q=*:*&fq={!geofilt%20pt=45.17614,-93.87341%20sfield=store%20d=5}

I get the right answer: 我得到了正确的答案:

{
        "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}

I will get no results. 我不会得到任何结果。 Is this a solr issue? 这是solr问题吗? Any solution? 有解决方案吗

Old question, but it's still in many Google search results, so here's more information for multi-valued coordinate fields: 老问题,但它仍然存在于许多谷歌搜索结果中,所以这里有更多关于多值坐标字段的信息:

You can add the following to your schema.xml: 您可以将以下内容添加到schema.xml:

<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
           spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
           distErrPct="0.025"
           maxDistErr="0.000009"
           units="degrees" />

Then use the location_rpt field for a multi-valued coordinate field, and benefit from all the advantages Solr 4's new spatial search offers. 然后将location_rpt字段用于多值坐标字段,并从Solr 4的新空间搜索提供的所有优势中受益。

You will also need to add the JTS jar to your solr class path if you use the custom spatialContextFactory. 如果使用自定义spatialContextFactory,还需要将JTS jar添加到solr类路径。 If you remove that parameter from the fieldType definition, multi-value fields still work, but other advanced features won't. 如果从fieldType定义中删除该参数,则多值字段仍然有效,但其他高级功能则不然。

According to the ticket (SOLR-2154) refered by vuky in d whelan's answer this should be in all new Solr releases. 根据vuky在d whelan的回答中提到的票证(SOLR-2154),这应该是在所有新的Solr版本中。 This was fixed by ticket SOLR-3304 ( https://issues.apache.org/jira/browse/SOLR-3304 ), which was marked as fixed at September 17, 2012. 这是通过机票SOLR-3304( https://issues.apache.org/jira/browse/SOLR-3304 )修复的,该机票已于2012年9月17日标记为已修复。

I can't really find a specific release from which it should work, but I suppose everything released after May 2013 should work if I read the comments in the tickets. 我无法真正找到它应该起作用的特定版本,但我想如果我阅读门票中的注释,2013年5月之后发布的所有内容都应该有效。

LatLon types can't be multiValued. LatLon类型不能是多值的。

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

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

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