# Duplicate field - Plugin custom

**URL:** <https://discuss.elastic.co/t/duplicate-field-plugin-custom/175078>\
**Category:** Elasticsearch\
**Created:** [April 2, 2019, 9:53pm UTC](https://discuss.elastic.co/t/duplicate-field-plugin-custom/175078 "2019-04-02T21:53:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [April 2, 2019, 9:53pm UTC](https://discuss.elastic.co/t/duplicate-field-plugin-custom/175078/1 "2019-04-02T21:53:45Z")

</div>

Hi guys, I have an error when creating the new CampoMapa that is specified in the add-on I'm working on. It tells me that the field is created duplicated. Any idea why it can be?

Query JSON

```auto
PUT example_event
{
    "settings": {
        "index": {
            "number_of_shards": 1,
            "number_of_replicas": 0
        }
    },
    "mappings": {
        "event": {
            "properties": {
                "recurrent_date": {
                    "type": "recurring"
                }
            }
        }
    }
}

```

Error

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "Failed to parse content to map",
        "suppressed": [
          {
            "type": "illegal_state_exception",
            "reason": "Failed to close the XContentBuilder"
          }
        ]
      }
    ],
    "type": "parse_exception",
    "reason": "Failed to parse content to map",
    "caused_by": {
      "type": "json_parse_exception",
      "reason": "Duplicate field 'recurrent_date'\n at [Source: org.elasticsearch.common.compress.DeflateCompressor$1@4d2e4bef; line: 1, column: 159]"
    },
    "suppressed": [
      {
        "type": "illegal_state_exception",
        "reason": "Failed to close the XContentBuilder",
        "caused_by": {
          "type": "i_o_exception",
          "reason": "Unclosed object or array found"
        }
      }
    ]
  },
  "status": 400
}

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 3, 2019, 8:02am UTC](https://discuss.elastic.co/t/duplicate-field-plugin-custom/175078/2 "2019-04-03T08:02:29Z")

</div>

Hey,

I assume you wrote your own mapper. Is it possible that this mapper is not fully consuming the supplied JSON data or too much of it when parsing the mapping type configuration?

--Alex

---

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [April 3, 2019, 5:31pm UTC](https://discuss.elastic.co/t/duplicate-field-plugin-custom/175078/3 "2019-04-03T17:31:53Z")

</div>

Thanks! 😃

---

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [April 3, 2019, 5:40pm UTC](https://discuss.elastic.co/t/duplicate-field-plugin-custom/175078/4 "2019-04-03T17:40:23Z")

</div>

Hello, I am creating a custom plugin and when making this query I have this error.

JSON

```auto
GET example_event/_search
{
  "query": {
    "bool" : {
      "filter" : {
        "script" : {
          "script" : {
            "source": "notHasExpired",
            "lang": "native",
            "params": {
              "field": "recurrent_date"
            }
          }
        }
      }
    }
  }
}

```

Error

```auto
"caused_by": {
      "type": "general_script_exception",
      "reason": "Failed to compile inline script [notHasExpired] using lang [native]",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "native scripts can not be used for context [filter]"
      }
    }

```

If code

```auto
if (context.equals(SearchScript.CONTEXT) == false) {
                //throw new IllegalArgumentException(getType() + " scripts cannot be used for context [" + context.name + "]");
            }

```

where compile receives  
ScriptName: notHasExpired  
scriptSource: notHasExpired  
ContextType: native  
ContextName: filter  
SearchScript.CONTEXT: org.elasticsearch.script.ScriptContext@3e5d4f6b

if I delete the condition of "SearchScript.CONTEXT == false" I have an error of "org.elasticsearch.script.FilterScript $ Factory" but I am using it is "SearchScript.Factory factory = hasAnyOccurrenceBetween :: new;"

Do you have any idea why?

---

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [April 4, 2019, 2:47pm UTC](https://discuss.elastic.co/t/duplicate-field-plugin-custom/175078/5 "2019-04-04T14:47:42Z")

</div>

Hello brot. can you help me with this please! 🙂

> [@Plugin Custom - Multi Source?](https://discuss.elastic.co/t/plugin-custom-multi-source/175439):
>
> Hi guys, I've been almost 1 month trying to migrate a plugin developed in 5.4 from elasticsearch to 6.6. What I want is to establish different sources of which in each one the dates entered are verified to show the available calendar or events or events that have not yet expired. Then an abstract method was created for each of the scripts by setting the "NativeScriptFactory" and. Plugin: import org.devmaster.elasticsearch.index.mapper.RecurringFieldMapper; import org.devmaster.elasticsearch.s…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 2, 2019, 2:47pm UTC](https://discuss.elastic.co/t/duplicate-field-plugin-custom/175078/6 "2019-05-02T14:47:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
