Hi All,
I am inserting a table into ES which contains a column that is of type Nested Jsonb (I am converting it to Json while extracting the data) in Postgres.
This is my logstash conf file:
input {
jdbc {
jdbc_connection_string => "jdbc:postgresql://myhostname:5432/mydb"
jdbc_user => "myusr"
jdbc_password => "mypwd"
jdbc_validate_connection => true
jdbc_driver_library => "/ELK/postgres/postgresql-9.4.1208.jar"
jdbc_driver_class => "org.postgresql.Driver"
statement => "SELECT to_json(business_det) from business limit 1"
}
}
filter{
json{
source => "%{[to_json][value]}"
}
}
output {
elasticsearch {
index => "abc"
document_type => "details"
# document_id => "%{business_id}"
# hosts => "localhost"
}
stdout{}
}
Ideally, I would like the Nested Json object (business_det) to be stored in the same nested json format in root document in ES.
But it's being stored in the field "value" within "to_json" and I am unable to do the above.
Here's how it looks:
{
"took" : 4,
"_shards" : {
"failed" : 0,
"successful" : 5,
"total" : 5
},
"timed_out" : false,
"hits" : {
"hits" : [
{
"_score" : 1,
"_index" : "abc",
"_source" : {
"@version" : "1",
"@timestamp" : "2016-08-18T21:45:29.222Z",
"to_json" : {
"value" : "{"gps": {"latitude": "41.15432", "longitude": "-74.35413"}, "name": "US Post Office", "aboutMe": "", "address": {"city": "Hewitt", "line1": "1926 Union Valley Rd Ste 3", "state": "NJ", "country": "USA", "zipCode": "07421"}, "category": "Post Offices", "phoneNum": [{"work": "(800) 275-8777"}], "openHours": ["Mon - Fri 8:30 am - 5:00 pm", " Sat 8:30 am - 12:30 pm", " Sun Closed"], "searchTags": [" Post Offices", "Mail & Shipping Services"]}",
"type" : "json"
}
},
"_type" : "details",
"_id" : "AVafnb8ftbvkzTn2myuI"
}
Here's my mapping:
curl -XPUT "http://localhost:9200/abc/_mapping/details" -d'
{
"details": {
"properties": {
"to_json": {
"type": "nested",
"properties": {
"name": {
"type" : "string",
"analyzer": "autocomplete"
},
"category": {
"type" : "string",
"analyzer": "autocomplete"
},
"aboutMe": {
"type" : "string",
"analyzer": "autocomplete"
},
"searchTags": {
"type" : "string",
"analyzer": "autocomplete"
}
}
}
}
}
}'
What am I doing wrong here?
Please let me know.
Thanks.