我为我的索引提供了JSON,如下所示:
{
"_index": "myindes",
"_type": "external",
"_id": "1",
"_source": {
"id": "1",
"name": "myName",
"description": "myDescription",
"source": "mySource",
}
}
我想在名为_source
topic
中添加一个字符串字段
我该怎么办
答案 0 :(得分:0)
您可以将索引映射更新为
select date_format(c.date, '%Y-%m') as yyyymm,
count(distinct c.name) as NumCustomers,
sum(case when date_format(c.date, '%Y-%m') <> date_format(cc.start_date, '%Y-%m')
then 1 else 0
end) as NumRepeatCustomers
from customers c join
(select c.name, min(c.date) as start_date
from customers c
group by c.name
) cc
on c.name = cc.name
group by date_format(c.date, '%Y-%m')
order by yyyymm;
虽然上述步骤不是必需的,但总是很好地控制你要编制索引的内容。
现在,您可以使用新字段索引文档,它将反映在新的更新中。但是,旧的索引文档仍然不包含此新字段。你将不得不重新索引它们。