1

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?

rethabile
  • 3,029
  • 6
  • 34
  • 68

1 Answers1

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.

Val
  • 207,596
  • 13
  • 358
  • 360
  • In my case i have `doctype` and `queries` as different types as in [here](https://stackoverflow.com/a/40688396/852243) to be indexed to different indices. – rethabile Aug 30 '17 at 07:26
  • Then you need to create two different indices, one with your message data and another with your queries. – Val Aug 30 '17 at 07:29
  • I tried that but it doesn't seems like i'm succeeding in indexing the query property – rethabile Aug 30 '17 at 08:31
  • I just spawned a new [thread](https://stackoverflow.com/questions/45956630/nest-ignoring-my-percolate-query-property) as it's more on the `Nest` side of things. – rethabile Aug 30 '17 at 09:25