我的问题与使用python进行弹性搜索有关 我知道我们可以做映射 通过这种方式
esearch.indices.create(index='test-index', body = request_body,ignore=400)
其中
request_body =
{"mappings":
{"TestDocType":
{
"properties":
{
"id":{"type":"integer"},
"name":{"type":"text"},
"description":{"type":"text"}
}
}
}
}
但是我想从这样的类中获取映射
import json
from elasticsearch_dsl import String, Integer, Float, Date, Boolean
from profile_doc import ProfileDocType
class TestDocType(ProfileDocType):
id = Integer()
title = String()
description = String()
class Meta:
index = "Test-index"
def serialize(self, prod):
return {
'id': prod.id,
'name': prod.title,
'description': prod.description,
}
其中ProfileDocType是
from datetime import datetime
from elasticsearch_dsl import DocType
class ProfileDocType(DocType):
def serialize(self, profile):
profile["updated_on"] = str(datetime.now())
return profile
我想获取TestDocType类的映射并将其添加到索引中 如何做到这一点? 如果您不明白我的意思,请检查c#弹性搜索https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/auto-map.html
中的自动映射您的帮助将不胜感激:)