creating an index for percolate query

China☆狼群 提交于 2019-12-11 15:28:48

问题


I'm trying percolate query in elasticsearch, but creating an index as explained in the docs I'm greeted with an error. I ran the following:

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

I'm greeted with the following error:

{
  "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
}

Am I missing something here?


回答1:


Since you're using ES 6, you just need to move the query field inside your mapping type

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

Note that as of ES 6, only a single mapping type is allowed within any index.



来源:https://stackoverflow.com/questions/45953606/creating-an-index-for-percolate-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!