我有2個單獨的索引,每個索引都包含不同的類型 我想從兩者中獲取組合記錄。elasticsearch index_name with multi_field
的問題是,一種類型具有字段「電子郵件」,其他有「work_email」。不過,我想將它們作爲排序目的相同的東西。 這就是爲什麼我嘗試在其中一種類型中使用index_name。
這裏是映射:
指數1:
"mappings": {
"people": {
"properties": {
"work_email": {
"type": "string",
"index_name": "email",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
索引2:
"mappings": {
"companies": {
"properties": {
"email": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
我希望這個工作:
GET /index1,index2/people,companies/_search?
{
"sort": [
{
"email.raw": {
"order": "asc"
}
}
]
}
但是,我得到一個錯誤,在「人員」類型中沒有這樣的字段。 我做錯了什麼,還是有更好的方法來實現我所需要的?
在這裏你可以找到一個休閒腳本說明了這個問題:https://gist.github.com/pmishev/11375297
你有沒有想過這個?發現這個問題研究同樣的問題。在我的情況下,我也指定了index_name,但結果相同。 – InfinitiesLoop