3
我现在在使用弹性搜索时遇到问题。当我尝试执行搜索并只希望返回一部分字段时,如果字段嵌套,则需要使用点符号指定字段。下面是它映射我的CouchDB文档我的映射JSON文件的样本:重命名弹性搜索输出字段
{
"product": {
"_type": {"store": "yes"},
"_source": {"compress": true},
"index_analyzer": "standard",
"search_analyzer": "standard",
"dynamic_date_formats": ["date_time_no_millis", "date_optional_time"],
"properties": {
"_id": {"type": "string", "store": "yes", "index": "not_analyzed"},
"key": {"type": "string", "store": "yes"},
"content": {
"type": "object",
"path": "just_name",
"properties": {
"key": {"type": "string", "store": "yes"},
"name": {"type": "string", "store": "yes", "index_name": "name"},
"description": {"type": "string", "store": "yes", "index_name": "description"},
"brand": {
"type": "object",
"index_name": "brand",
"properties": {
"abbreviation": {"type": "string", "store": "yes", "index_name": "brand_abbreviation"},
"name": {"type": "string", "store": "yes", "index_name": "brand_name"}
}
}
}
}
}
}
}
参考_id将只是一个简单的_id,但说我想指的名字的内容,我就不得不提到它作为content.name。这样做的问题是,当搜索输出结束时,json输出包含字段名称:“content.name”。
是否有可能将其重命名为“名称”而没有“内容”。字首?你可以看到,我试图指定index_name,但似乎没用。
首先我要感谢您回复此问题。这是我迄今收到的关于弹性搜索的第一个体面的答案!即使是邮件列表或IRC频道也没有多大帮助! 是的,_id字段是外部ID。 为什么我要存储所有字段?我真的不知道;听起来好像我不存储它们,意味着它们不会被索引。谢谢你的提示。总而言之,我觉得这些文档在一些真实世界的例子或非常详细的例子中是不存在的。你已经帮了我很多,谢谢! – Mark 2012-08-14 03:26:03
嗯......我想接受这个答案,但是请你帮我解释一下我的意见吗? – Mark 2012-08-24 08:07:18