0
votes

I am using Elasticsearch 1.4

I have an Index:

curl -XPUT "http://localhost:49200/customer" -d '{"mappings": {"venues": {"properties": {"party_id": {"type": "string"},"sup_party_id": {"type": "string"},"location": {"type": "geo_point"}            }       }    }}'

And put some data, for instances:

curl -XPOST "http://localhost:49200/customer/venues/RO2" -d '{ "party_id":"RO2",  "sup_party_id": "SUP_GT_R1A_0001","location":{ "lat":"21.030347","lon":"105.842896" }}'
curl -XPOST "http://localhost:49200/customer/venues/RO3" -d '{ "party_id":"RO3",  "sup_party_id": "SUP_GT_R1A_0004","location":{ "lat":"20.9602051","lon":"105.78709179999998" }}'

and my filter is:

{"constant_score":
    {"filter":
        {"and":
            [{"terms":
                {"sup_party_id":["SUP_GT_R1A_0004","SUP_GT_R1A_0001","RO2","RO3","RO4"]
                }
            },{"geo_bounding_box":
                {"location":
                    {"top_left":{"lat":25.74546096707413,"lon":70.43503197075188},
                    "bottom_right":{"lat":6.342579199578783,"lon":168.96042259575188}
                    }
                }
            }]
        }
    }
}

the above query does not return data but It return data when I remove the following terms:

{"terms":
    {"sup_party_id":["SUP_GT_R1A_0004","SUP_GT_R1A_0001","RO2","RO3","RO4"]
    }
}

Please show me the problem, any suggestions is appreciated!

1

1 Answers

1
votes

That's because the sup_party_id field is an analyzed string. Change your mapping like this instead and it will work:

curl -XPUT "http://localhost:49200/customer" -d '{
  "mappings": {
    "venues": {
      "properties": {
        "party_id": {
          "type": "string"
        },
        "sup_party_id": {
          "type": "string",
          "index": "not_analyzed"     <--- add this
        },
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}'