2017-08-30 123 views
0

我試圖在elasticsearch中滲透查詢,但創建一個索引,如docs中所解釋的,我遇到了一個錯誤。我跑了以下內容:創建percolate查詢的索引

PUT /my_percolate_index 
{ 
    "mappings": { 
    "doctype": { 
     "properties": { 
      "message": { 
       "type": "text" 
      } 
     } 
    }, 
    "queries": { 
     "properties": { 
      "query": { 
       "type": "percolator" 
      } 
     } 
    } 
    } 
} 

我笑臉相迎以下錯誤:

{ 
    "error": { 
    "root_cause": [ 
    { 
     "type": "illegal_argument_exception", 
     "reason": "Rejecting mapping update to [my_percolate_index] as the final mapping would have more than 1 type: [doctype, queries]" 
    } 
    ], 
    "type": "illegal_argument_exception", 
    "reason": "Rejecting mapping update to [my_percolate_index] as the final mapping would have more than 1 type: [doctype, queries]" 
    }, 
    "status": 400 
} 

這裏我錯過什麼?

+0

您使用的是哪個版本的ES? – Val

+0

'ES 6.0.0-alpha1'和'NEST 6.0.0-alpha1' –

回答

0

Since you're using ES 6,你只需要移動你的映射類型裏面的query

PUT /my_percolate_index 
{ 
    "mappings": { 
     "doctype": { 
      "properties": { 
       "message": { 
        "type": "text" 
       }, 
       "query": { 
        "type": "percolator" 
       } 
      } 
     } 
    } 
} 

注意,作爲ES 6中,只有一個類型的映射允許任何索引中。

+0

在我的情況下,我有'doctype'和'queries'作爲不同的類型在[這裏](https://stackoverflow.com/a/ 40688396/852243)被索引到不同的指數。 –

+0

然後你需要創建兩個不同的索引,一個用你的消息數據,另一個用你的查詢。 – Val

+0

我試過,但它似乎並不像我成功索引查詢屬性 –