creating an index for percolate query

2019-09-16 19:20发布

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条回答
我命由我不由天
2楼-- · 2019-09-16 20:20

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.

查看更多
登录 后发表回答