question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"No handler for type [string] declared on field [test]" after update to ES6

See original GitHub issue

Hi!

After updating from Elasticsearch 5.5.1 -> 6.1.1 (and corresponding elasticsearch-py and elasticsearch-dsl-py 5.x -> 6.x updates; running under Python 2.7) I get:

...
  File "/home/vagrant/treeherder/treeherder/model/search.py", line 197, in _init
    item.init()
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch_dsl/document.py", line 152, in init
    cls._doc_type.init(index, using)
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch_dsl/document.py", line 85, in init
    self.mapping.save(index or self.index, using=using or self.using)
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch_dsl/mapping.py", line 116, in save
    return index.save()
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch_dsl/index.py", line 219, in save
    return self.create()
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch_dsl/index.py", line 203, in create
    self.connection.indices.create(index=self._name, body=self.to_dict(), **kwargs)
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 76, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch/client/indices.py", line 91, in create
    params=params, body=body)
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch/transport.py", line 314, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 161, in perform_request
    self._raise_error(response.status, raw_data)
  File "/home/vagrant/python/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 125, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, u'mapper_parsing_exception', u'No handler for type [string] declared on field [test]')

Enabling elasticsearch.trace logging I see the request being made was:

[2018-01-02 14:38:52,749] INFO [elasticsearch.trace:67] curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/test-test-failure-line?pretty' -d '{
  "mappings": {
    "doc": {
      "properties": {
        "best_classification": {
          "index": "not_analyzed",
          "type": "integer"
        },
        "best_is_verified": {
          "index": "not_analyzed",
          "type": "boolean"
        },
        "expected": {
          "index": "not_analyzed",
          "type": "string"
        },
        "job_guid": {
          "index": "not_analyzed",
          "type": "string"
        },
        "message": {
          "analyzer": "message_analyzer",
          "type": "string"
        },
        "status": {
          "index": "not_analyzed",
          "type": "string"
        },
        "subtest": {
          "index": "not_analyzed",
          "type": "string"
        },
        "test": {
          "index": "not_analyzed",
          "type": "string"
        }
      }
    }
  },
  "settings": {
    "analysis": {
      "analyzer": {
        "message_analyzer": {
          "filters": [],
          "tokenizer": "message_tokenizer",
          "type": "custom"
        }
      },
      "tokenizer": {
        "message_tokenizer": {
          "pattern": "0x[0-9a-fA-F]+|[\\W0-9]+?",
          "type": "pattern"
        }
      }
    }
  }
}'
[2018-01-02 14:38:52,749] DEBUG [elasticsearch.trace:70] #[400] (0.016s)
#{
#  "error": {
#    "caused_by": {
#      "reason": "No handler for type [string] declared on field [test]",
#      "type": "mapper_parsing_exception"
#    },
#    "reason": "Failed to parse mapping [doc]: No handler for type [string] declared on field [test]",
#    "root_cause": [
#      {
#        "reason": "No handler for type [string] declared on field [test]",
#        "type": "mapper_parsing_exception"
#      }
#    ],
#    "type": "mapper_parsing_exception"
#  },
#  "status": 400
#}

I believe this is coming from the usage of the field type String, here: https://github.com/mozilla/treeherder/blob/2adb7b93dc9148eda66998e85a0ca20d1e986ecd/treeherder/model/search.py#L68-L75

Looking at the changelog for elasticsearch-dsl 5.0.0, I see: String field type has been deprecated in favor of Text and Keyword

…so presumably this is related to that?

However if Elasticsearch 6 no longer supports string, then:

  1. it seems like it should be removed from elasticsearch-dsl to prevent confusion / reduce the time spent debugging this? (Or at least a visible deprecation message logged somewhere?)
  2. it would be great for the elasticsearch-dsl 6.0 release notes to mention it’s now changed from deprecated to “doesn’t work”

After figuring that out, I tried importing/using Text instead of String, however I then get: elasticsearch.exceptions.RequestError: TransportError(400, u'mapper_parsing_exception', u'Failed to parse mapping [doc]: Could not convert [test.index] to boolean')

Both of these feel like things that perhaps would be best caught in the client to ease debugging?

Many thanks 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

30reactions
honzakralcommented, Jan 2, 2018

Hi, indeed it is caused by that - string is deprecated and you should be using text or keyword instead.

string can still, however, exist in a mapping in a 6.x cluster if the index was created before the upgrade, that is why it is still present in the library. We will most likely remove it soon though in order to avoid similar confusion, thank you for the report!

Hope this helps!

1reaction
willtucommented, May 28, 2018

So how to solve the problem occurs after changing from “string” to “text”?

elasticsearch.exceptions.RequestError: TransportError(400, u’mapper_parsing_exception’, u’Failed to parse mapping [doc]: Could not convert [test.index] to boolean’)

Read more comments on GitHub >

github_iconTop Results From Across the Web

No handler for type [string] declared on field [name]
Elasticsearch has dropped the string type and is now using text . So your code should be something like this "name" => [...
Read more >
No handler for type [string] declared on field [fieldname]
I know this question has been asked before but I can't seem to make this work. I updated Kibana and ElasticSearch from 5.6.16...
Read more >
Fixing Elasticsearch error: No handler for type [string] declared ...
Got Elasticsearch error: "No handler for type [string] declared on field" after upgrading to ES 6.x? Then update index templates and be ES...
Read more >
No handler for type ” + type + ” declared on field ” + fieldName ...
A detailed guide on how to resolve errors related to "No handler for type " + type + " declared on field "...
Read more >
typescript-cheatsheet - GitHub Pages
The cheatsheet contains references to types, classes, decorators, and many other ... If no types are declared, TypeScript will automatically assign a type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found