
SolrInputDocument::getChildDocuments 메서드는 자식 문서를 반환하는 메서드입니다.
이 메서드는 다음과 같은 상황에서 호출되어야 합니다.
1. 문서의 계층 구조: SolrInputDocument 클래스는 문서의 계층 구조를 표현하기 위해 사용됩니다. 예를 들어, 제품의 카테고리, 브랜드, 모델과 같은 계층 구조를 표현할 때 사용됩니다. 이 경우, getChildDocuments 메서드는 특정 문서의 자식 문서를 반환합니다.
2. 문서의 관계: SolrInputDocument 클래스는 문서의 관계를 표현하기 위해 사용됩니다. 예를 들어, 제품과 제품의 리뷰, 제품과 제품의 추천과 같은 관계를 표현할 때 사용됩니다. 이 경우, getChildDocuments 메서드는 특정 문서의 관계 문서를 반환합니다.
getChildDocuments 메서드는 다음과 같은 정보를 포함합니다.
* 문서 ID: 반환되는 문서의 ID입니다.
* 문서 유형: 반환되는 문서의 유형입니다. 예를 들어, 제품, 카테고리, 브랜드, 모델, 리뷰, 추천 등이 있습니다.
* 문서 속성: 반환되는 문서의 속성입니다. 예를 들어, 제품의 이름, 가격, 브랜드, 모델 등이 있습니다.
예를 들어, 다음과 같이 getChildDocuments 메서드를 사용할 수 있습니다.
#hostingforum.kr
java
SolrInputDocument parentDocument = new SolrInputDocument();
parentDocument.addField("id", "parent-document-id");
parentDocument.addField("type", "product");
SolrInputDocument childDocument1 = new SolrInputDocument();
childDocument1.addField("id", "child-document-id-1");
childDocument1.addField("type", "review");
childDocument1.addField("product_id", "parent-document-id");
SolrInputDocument childDocument2 = new SolrInputDocument();
childDocument2.addField("id", "child-document-id-2");
childDocument2.addField("type", "recommendation");
childDocument2.addField("product_id", "parent-document-id");
parentDocument.addField("childDocuments", childDocument1);
parentDocument.addField("childDocuments", childDocument2);
List childDocuments = parentDocument.getChildDocuments();
이 예제에서는 getParentDocument 메서드를 사용하여 특정 문서의 자식 문서를 반환합니다. 반환된 자식 문서는 다음과 같은 정보를 포함합니다.
* 문서 ID: "child-document-id-1"과 "child-document-id-2"
* 문서 유형: "review"과 "recommendation"
* 문서 속성: "product_id" 필드에 "parent-document-id"가 포함됩니다.
2025-03-05 23:51