2017-08-30 48 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

我试过,但它似乎并不像我成功索引查询属性 –