Elasticsearch-dsl-py を使用して、多くのフィールドを持つ jsonl ファイルからいくつかのデータにインデックスを付けようとしています。一般的でない部分を無視すると、コードは次のようになります。
es = Elasticsearch()
for id,line in enumerate(open(jsonlfile)):
jline = json.loads(line)
children = jline.pop('allChildrenOfTypeX')
res = es.index(index="mydocs", doc_type='fatherdoc', id=id, body=jline)
for ch in children:
res = es.index(index="mydocs", doc_type='childx', parent=id, body=ch)
これを実行しようとすると、エラーで終了します:
RequestError: TransportError(400, u'illegal_argument_exception', u"Can't specify parent if no parent field has been configured")
親を持つ es を事前に伝える必要があると思います。ただし、私が望んでいないのは、両方のすべてのフィールドをマップすることです。
どんな助けでも大歓迎です!