簡體   English   中英

Python ElasticSearch DSL:如何映射未分析的字符串字段?

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

示例代碼仍然創建分析的 ES 字符串字段。

試過這個:

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

而這個:

username = String(index="not_analyzed")

嘗試在定義username的類上調用<className>.init() 那應該在 ES 中創建映射。

有關更多信息,請參閱http://elasticsearch-dsl.readthedocs.io/en/latest/persistence.html?highlight=init#document-life-cycle

對於最新的 elasticsearch, String數據類型被替換為TextKeyword

所以為了不分析字符串,

from elasticsearch_dsl import Keyword

username = Keyword(index=False)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM