Skip to content

Instantly share code, notes, and snippets.

@jettro
Last active October 31, 2017 07:57
Show Gist options
  • Select an option

  • Save jettro/94a52a618fa3bc12387dcd911503907d to your computer and use it in GitHub Desktop.

Select an option

Save jettro/94a52a618fa3bc12387dcd911503907d to your computer and use it in GitHub Desktop.
Example configs to import the Signal Media News dataset into elasticsearch using logstash
curl -XGET "http://localhost:9200/signalmedia/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"content": "rain"
}
},
"aggs": {
"my_sampler": {
"sampler": {
"shard_size": 200
},
"aggs": {
"keywords": {
"significant_text": {
"field": "content",
"filter_duplicate_text": true
}
}
}
}
},
"size": 0
}'
# bin/logstash -f ../configs/signalmedia.conf
input {
file {
path => "/Volumes/Transcend/signalmedia-1m.jsonl"
codec => "json"
start_position => beginning
}
}
filter {
mutate {
copy => {"id" => "[@metadata][id]"}
}
mutate {
remove_field => ["@timestamp", "@version", "host", "message", "path", "id"]
}
}
output {
elasticsearch {
index => "signalmedia"
document_id => "%{[@metadata][id]}"
document_type => "doc"
manage_template => "true"
template => "./signalmedia-template.json"
template_name => "signalmediatemplate"
}
stdout { codec => dots }
}
{
"index_patterns": ["signalmedia"],
"settings": {
"number_of_replicas": 0,
"number_of_shards": 3
},
"mappings": {
"doc": {
"properties": {
"source": {
"type": "keyword"
},
"published": {
"type": "date"
},
"title": {
"type": "text"
},
"media-type": {
"type": "keyword"
},
"content": {
"type": "text"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment