lairtech
lairtech

Reputation: 2417

Python ElasticSearch DSL: How to map String field that's not analyzed?

The sample code still creates ES string field that's analyzed.

Tried this:

username = String(fields={'raw': String(index='not_analyzed')})

And this:

username = String(index="not_analyzed")

Upvotes: 3

Views: 1682

Answers (2)

WcW
WcW

Reputation: 511

For the latest elasticsearch, String datatype is replaced by Text and Keyword

So for not analyze the string,

from elasticsearch_dsl import Keyword

username = Keyword(index=False)

Upvotes: 0

concrete_d
concrete_d

Reputation: 370

Try calling <className>.init() on the class where you're defining username. That should create the mappings in ES.

See http://elasticsearch-dsl.readthedocs.io/en/latest/persistence.html?highlight=init#document-life-cycle for more info.

Upvotes: 1

Related Questions