Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mapping:
- PUT pets
- {
- "mappings": {
- "myPets": {
- "_all": { "enabled": false },
- "dynamic": "strict",
- "properties": {
- "user": { "type": "text" },
- "pets": {
- "type": "nested",
- "properties": {
- "name": { "type": "text" },
- "type": { "type": "text" },
- "breed": { "type": "text" },
- "description": { "type": "text" }
- }
- }
- }
- }
- }
- }
- Example entry (GET pets/_search?q=*:*):
- {
- "took": 157,
- "timed_out": false,
- "_shards": {
- "total": 5,
- "successful": 5,
- "failed": 0
- },
- "hits": {
- "total": 1,
- "max_score": 1,
- "hits": [
- {
- "_index": "pets",
- "_type": "myPets",
- "_id": "UE2hJtfwIF88L7XDQmOo",
- "_score": 1,
- "_source": {
- "pets": {
- "name": "Nils",
- "type": "dog",
- "breed": "sheepdog",
- "description": "hairy"
- },
- "user": "jacob"
- }
- }
- ]
- }
- }
- logstash configuration:
- input {
- jdbc {
- jdbc_connection_string => "jdbc:mysql://localhost:3306/pets"
- jdbc_user => "root"
- jdbc_password => "st40ngP@ssw0rd"
- jdbc_driver_library => "D:\mysql-connector-java-5.1.42-bin.jar"
- jdbc_driver_class => "com.mysql.jdbc.Driver"
- statement => "SELECT name, type, breed, description FROM pets"
- }
- }
- filter {
- mutate {
- rename => {
- "name" => "[pets][name]"
- "type" => "[pets][type]"
- "breed" => "[pets][breed]"
- "description" => "[pets][description]"
- }
- remove_field => [
- "@timestamp",
- "@version"
- ]
- }
- }
- output {
- stdout { codec => json_lines }
- elasticsearch {
- "hosts" => "localhost:9200"
- "index" => "pets"
- "document_type" => "myPets"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement