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