Я пытаюсь получить вложенный объект, используя вложенный тип данных, из упругого поиска, используя logstash со следующим файлом конфигурации с именем "export-nested.conf"
input {
elasticsearch {
hosts => "localhost:9200"
index => "test"
query => '
{"query": {
"nested": {
"path": "comments",
"query": {
"match": {"comments.active": true}
},
"inner_hits": {
"highlight": {
"fields": {
"comments.active": {}
}
}
}
}
}}'
}
}
output {
csv {
fields => ["comments.author","comments.number"]
path => "output.csv"
}
}
Воспроизвести проблему: Шаг 1: - Я создал нижеиндекс со следующим отображением
PUT test
{
"mappings": {
"_doc": {
"properties": {
"comments": {
"type": "nested"
}
}
}
}
}
step2: - Введенные данные в индекс, который я создал:
PUT test/_doc/1?refresh
{
"title": "Test1",
"comments": [
{
"author": "elis",
"number": 1,
"active": true
},
{
"author": "zara",
"number": 2,
"active": false
}
]
}
PUT test/_doc/2?refresh
{
"title": "Test2",
"comments": [
{
"author": "john",
"number": 3,
"active": false
},
{
"author": "rob",
"number": 4,
"active": true
}
]
}
Step3: - Использовал следующую команду для запуска logstash
bin/logstash -f export-nested.conf
Вывод: я получаю пустые данные в выходном файле.
,
,
Ожидаемый вывод:
elis,1
rob,4