라이브러리
[PHP] SolrDocument::clear - 문서의 모든 필드를 삭제합니다.
PHP에서 SolrDocument::clear
SolrDocument는 Solr에서 문서를 나타내는 클래스입니다. 이 클래스는 문서의 필드를 설정, 삭제, 수정하는 메소드를 제공합니다.
# clear 메소드
SolrDocument::clear 메소드는 문서의 모든 필드를 삭제합니다. 이 메소드는 문서를 초기화하는 데 사용할 수 있습니다.
# 예제
#hostingforum.kr
php
use SolariumQueryTypeDeleteQueryQuery;
use SolariumQueryTypeDeleteQueryQueryInterface;
use SolariumCoreQueryUpdateQueryDocument;
use SolariumCoreQueryUpdateQueryDocumentInterface;
// SolrDocument 인스턴스 생성
$document = new Document();
// 필드 설정
$document->addField('id', '1');
$document->addField('name', 'John Doe');
$document->addField('age', 30);
// clear 메소드 호출
$document->clear();
// 필드 확인
echo $document->getField('id') ? 'id 필드는 존재합니다.' : 'id 필드는 존재하지 않습니다.';
echo $document->getField('name') ? 'name 필드는 존재합니다.' : 'name 필드는 존재하지 않습니다.';
echo $document->getField('age') ? 'age 필드는 존재합니다.' : 'age 필드는 존재하지 않습니다.';
# 결과
#hostingforum.kr
id 필드는 존재하지 않습니다.
name 필드는 존재하지 않습니다.
age 필드는 존재하지 않습니다.
# 설명
SolrDocument::clear 메소드는 문서의 모든 필드를 삭제합니다. 이 예제에서는 id, name, age 필드를 설정한 후 clear 메소드를 호출하여 모든 필드를 삭제합니다. 결과적으로 id, name, age 필드는 존재하지 않습니다.
# 참고
SolrDocument::clear 메소드는 문서를 초기화하는 데 사용할 수 있습니다. 이 메소드는 문서를 삭제하는 대신 문서의 필드를 삭제하는 데 사용할 수 있습니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.