假设我有一个名为participant_tests
的文档和一个名为participant_test_question_answers
的子类型,在我的情况下,我应该在创建和映射其子{{1}之前始终索引participant_tests
}}。
我有以下儿童类型的映射:
(participant_test_question_answers)
现在,当我想索引子类型时,它会显示以下错误:
protected $mappingProperties = array(
'index' => 'my_index',
'type' => 'participant_test_question_answers',
'body' => [
"participant_tests" => [],
'participant_test_question_answers' => [
'_source' => [
'type' => 'string',
'analyzer' => 'standard'
],
"_parent" => [
"type" => "participant_tests"
],
'properties' => [
'id' => array("type" => "string"),
'participant_test_qu_id' => array("type" => "string"),
'bank_answer' => array(
'type' => 'nested',
"properties" => array(
"id" => array("type" => "string"),
"test_answer_text_en" => array("type" => "string"),
"test_answer_text_pr" => array("type" => "string"),
"test_answer_text_pa" => array("type" => "string"),
"correctness" => array("type" => "string"),
"is_selected" => array("type" => "string"),
)
),
'created_at' => array(
'type' => 'date',
"format"=>"YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd"
),
'updated_at' => array(
'type' => 'date',
"format" => "YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd"
),
'deleted_at' => array(
'type' => 'date',
"format" => "YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd"
),
'created_by' => array(
'type' => 'nested'
),
'updated_by' => array(
'type' => 'nested'
),
'deleted_by' => array(
'type' => 'nested'
)
]
]
]
);
此函数返回映射数组:
$client4testAnswer = ClientBuilder::create()->build();
// Update the index mapping
$client4testAnswer->indices()->putMapping($questionTestAnswerObject->getResourceMapping());
$qTstAnswerParams = [
"index" => "my_index",
"type" => "participant_test_question_answers",
"id" => uniqid(),
"parent" => $participant_test_doc_id,
"body" => [
// body content
]
];
$client4testAnswer->index($qTstAnswerParams);
错误:
function getResourceMapping(){
return $this->mappingProperties;
}
不知道为什么?
是否必须在父母或子女的任何索引编制之前创建父子的映射?