I have a Postgresql 9.1 table that includes columns "city", "admin1", and "country". I would like to select unique values with the output format of "city, admin1, country".
I may have multiple entries for New York and Rochester, Minnesota, but I only want one of each. This is to populate an elastic search index and I am using the JDBC river plugin
The following SELECT does what I want in PGAdmin3's SQL editor:
SELECT city || ', ' || admin1 || ', ' || country AS city FROM table GROUP BY city, admin1, country;
but fails in the following
curl -XPUT 'localhost:9200/_river/nibbel_river/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"driver" : "org.postgresql.Driver",
"url" : "jdbc:postgresql://localhost:5432/table",
"user" : "",
"password" : "",
"sql" : "SELECT city || ', ' || admin1 || ', ' || country AS city FROM everything GROUP BY city, admin1, country",
"poll" : "7d"
},
"index" : {
"index" : "city",
"type" : "everything"
}
}'
with the error
curl: (6) Couldn't resolve host ' || admin1 || ,'
curl: (3) [globbing] unmatched close brace/bracket at pos 102
{"error":"MapperParsingException[Failed to parse [jdbc.sql]]; nested: JsonParseException[Unexpected end-of-input in VALUE_STRING\n at [Source: [B@1192b0c; line: 8, column: 565]]; ","status":400}
What is the syntax for this?