4
votes

I can index multiple values for location type field in solr. The response for a modified schema.xml and indexing modified exampledocs looks like the query:

  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. 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? Any solution?

3
Can you show us the query that you are using where no results are being returned.Paige Cook
I updated the question, sorry for delay, but it was weekend ;)vuky

3 Answers

5
votes

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:

<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.

You will also need to add the JTS jar to your solr class path if you use the custom spatialContextFactory. If you remove that parameter from the fieldType definition, multi-value fields still work, but other advanced features won't.

2
votes

According to the ticket (SOLR-2154) refered by vuky in d whelan's answer this should be in all new Solr releases. This was fixed by ticket SOLR-3304 (https://issues.apache.org/jira/browse/SOLR-3304), which was marked as fixed at September 17, 2012.

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.