맞춤 날짜 형식 Java | GroupDocs와 날짜 범위 검색
날짜별 문서 검색은 흔한 요구사항입니다—아카이브 시스템, 재무 보고 도구, 혹은 콘텐츠 관리 포털을 구축하든 말든. 이 튜토리얼에서는 GroupDocs.Search를 사용한 custom date format java 기술을 배우게 되며, 날짜 범위 쿼리, 사용자 정의 패턴 정의, 그리고 검색 성능 최적화에 대한 팁을 다룹니다. 끝까지 진행하면 사용자가 어떤 형식이든 관계없이 원하는 날짜 구간에 해당하는 레코드를 검색할 수 있게 됩니다.
빠른 답변
- 인덱싱을 위한 기본 클래스는 무엇인가요?
Indexfrom thecom.groupdocs.searchpackage. - 사용자 정의 날짜 패턴을 어떻게 정의하나요? Use
DateFormatwithDateFormatElementobjects and a separator. - 텍스트 쿼리로 검색할 수 있나요? Yes, the
daterange(start ~~ end)syntax works directly in the query string. - 필요한 Maven 좌표는 무엇인가요?
com.groupdocs:groupdocs-search:25.4(or newer). - 개발에 라이선스가 필요합니까? A free trial or temporary license is sufficient for testing; a commercial license is required for production.
custom date format java란 무엇인가요?
A custom date format java는 GroupDocs.Search가 기본 ISO 패턴(YYYY‑MM‑DD)을 따르지 않는 날짜 문자열을 해석하는 방법을 알려줍니다. MM/dd/yyyy 또는 dd‑MM‑yyyy와 같은 자체 패턴을 정의함으로써, 지역 또는 레거시 형식을 사용하는 문서에 포함된 날짜를 엔진이 인식하도록 할 수 있습니다.
날짜 범위 쿼리에 GroupDocs.Search를 사용하는 이유
- 속도: Built‑in indexing makes look‑ups O(log n).
- 유연성: Supports both text‑based and object‑based query creation.
- 다중 형식 지원: Handles PDFs, Word, Excel, plain text, and more without extra code.
GroupDocs.Search를 사용한 search documents by date 방법
아래에서는 라이브러리 설정, 파일 인덱싱, 그리고 간단한 날짜 범위 검색과 고급 날짜 범위 검색을 실행하는 단계별 가이드를 제공합니다.
사전 요구 사항
- Java 8 이상이 설치되어 있어야 합니다.
- 의존성 관리를 위한 Maven.
- 개발을 위한 GroupDocs.Search 라이선스 접근 (체험판 또는 임시 라이선스 사용 가능).
Java용 GroupDocs.Search 설정
Maven을 사용한 설치
pom.xml에 저장소와 의존성을 추가합니다:
<repositories>
<repository>
<id>repository.groupdocs.com</id>
<name>GroupDocs Repository</name>
<url>https://releases.groupdocs.com/search/java/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-search</artifactId>
<version>25.4</version>
</dependency>
</dependencies>
직접 다운로드
또는 최신 버전을 직접 GroupDocs.Search for Java releases에서 다운로드할 수 있습니다.
기본 초기화 및 설정
Index 인스턴스를 생성하고 문서를 추가합니다:
import com.groupdocs.search.*;
String indexFolder = "YOUR_INDEX_DIRECTORY";
String documentsFolder = "YOUR_DOCUMENTS_DIRECTORY";
// Creating an index in the specified folder
Index index = new Index(indexFolder);
// Indexing documents from the specified folder
index.add(documentsFolder);
기능 1: 날짜 범위 검색 쿼리 만들기
텍스트 형태 쿼리 사용
가장 간단한 방법은 날짜 범위를 쿼리 문자열에 직접 삽입하는 것입니다:
import com.groupdocs.search.*;
import com.groupdocs.search.results.*;
// Define directories (as previously shown)
Index index = new Index(indexFolder);
index.add(documentsFolder);
// Create a text-based query for the specified date range
String query1 = "daterange(2017-01-01 ~~ 2019-12-31)";
SearchResult result1 = index.search(query1);
설명: The daterange syntax expects dates in YYYY‑MM‑DD. It returns all documents whose indexed dates fall within the interval.
Query 객체 사용
프로그램matic 제어와 사용자 정의 파싱을 위해 SearchQuery 객체를 구축합니다:
import com.groupdocs.search.*;
import com.groupdocs.search.options.*;
import com.groupdocs.search.results.*;
// Define directories (as previously shown)
Index index = new Index(indexFolder);
index.add(documentsFolder);
// Create a date range query using the Query API
SearchQuery query2 = SearchQuery.createDateRangeQuery(Utils.createDate(2017, 1, 1), Utils.createDate(2019, 12, 31));
SearchResult result2 = index.search(query2);
설명: createDateRangeQuery lets you supply java.util.Date objects, giving you full flexibility over time zones and locale‑specific handling.
기능 2: custom date format java 패턴 지정
사용자 정의 날짜 형식 설정
문서의 날짜 표현과 일치하는 DateFormat을 정의합니다:
import com.groupdocs.search.*;
import com.groupdocs.search.options.*;
import com.groupdocs.search.results.*;
// Define directories (as previously shown)
Index index = new Index(indexFolder);
index.add(documentsFolder);
// Configure search options with custom date formats
SearchOptions options = new SearchOptions();
options.getDateFormats().clear(); // Remove default formats
DateFormatElement[] elements = new DateFormatElement[]{
DateFormatElement.getMonthTwoDigits(),
DateFormatElement.getDateSeparator(),
DateFormatElement.getDayOfMonthTwoDigits(),
DateFormatElement.getDateSeparator(),
DateFormatElement.getYearFourDigits()
};
// Create a custom date format pattern 'MM/dd/yyyy'
DateFormat dateFormat = new DateFormat(elements, "/");
options.getDateFormats().addItem(dateFormat);
String query = "daterange(01/01/2017 ~~ 12/31/2019)";
SearchResult result = index.search(query, options);
설명: 기본 형식을 비우고 구분자로 /를 사용하는 DateFormat을 추가함으로써, 엔진은 이제 MM/dd/yyyy 형식의 날짜를 이해합니다. 이는 월‑우선 표기를 선호하는 지역에서 search documents by date에 필수적입니다.
검색 성능 최적화 팁
- 점진적 인덱싱: 기존 인덱스에 새 파일을 추가하고 처음부터 다시 구축하지 않습니다.
- 오래된 데이터 정리: 필요하지 않은 문서를 주기적으로 제거합니다.
- 메모리 설정 조정: 대규모 인덱스를 사용할 때 JVM 힙(
-Xmx)을 늘립니다.
일반적인 문제와 해결책
- 날짜 파싱 오류: 문서의 날짜 문자열이 정의한 사용자 정의 패턴과 정확히 일치하는지 확인하십시오.
- 결과 없음: 인덱싱된 필드에 날짜 메타데이터가 포함되어 있는지 확인하십시오; 그렇지 않으면 엔진이 날짜 쿼리를 매치할 수 없습니다.
- 인덱스 접근 예외:
indexFolder경로가 쓰기 가능하고 다른 프로세스에 의해 잠겨 있지 않은지 확인하십시오.
실용적인 적용 사례
- Archival Systems – 특정 역사적 기간의 레코드를 검색합니다.
- Content Management – 유럽 사용자들을 위해
dd/MM/yyyy와 같은 지역 날짜 형식을 지원합니다. - Financial Software – 회계 분기 또는 연도별로 거래를 빠르게 필터링합니다.
이것이 중요한 이유
custom date format java 처리를 구현하면 문서 전반에 걸친 일관되지 않은 날짜 표현을 다루는 어려움을 없앨 수 있습니다. 이를 통해 단일 인덱스에서 handle multiple date formats를 지원하여, 최종 사용자가 날짜가 어떻게 기록되었든 정확한 결과를 얻을 수 있습니다.
다음 단계
AND,OR,NOT연산자를 사용한 보다 고급 쿼리 조합을 탐색합니다.- 추가 시간 메타데이터를 인덱싱해야 할 경우 사용자 정의 분석기를 실험합니다.
- 수백만 개 문서에 대한 확장을 위해 공식 문서의 성능 튜닝 가이드를 검토합니다.
자주 묻는 질문
Q: 텍스트 형태와 객체 기반 날짜 쿼리의 차이점은 무엇인가요?
A: 텍스트 형태는 빠르고 간편하지만 기본 ISO 형식에 제한됩니다; 객체 기반 쿼리는 Date 객체와 사용자 정의 형식을 제공하여 더 큰 유연성을 제공합니다.
Q: 단일 쿼리에서 여러 날짜 범위를 검색할 수 있나요?
A: 예, daterange 절을 AND 또는 OR 같은 논리 연산자와 결합하여 복합 쿼리를 만들 수 있습니다.
Q: 사용자 정의 날짜 형식이 검색 속도를 저하시킬까요?
A: 추가 파싱으로 인한 약간의 오버헤드가 있지만, 일반적인 작업 부하에서는 영향이 미미하며 정확도 향상이 이를 상쇄합니다.
Q: GroupDocs.Search는 대규모 배포에 적합한가요?
A: 물론입니다. 적절한 인덱싱 전략과 JVM 튜닝을 통해 수백만 개 문서까지 확장할 수 있습니다.
Q: 더 많은 Java 예제를 어디서 찾을 수 있나요?
A: 추가 샘플 및 사용 사례 구현을 위해 GroupDocs GitHub repository를 확인하십시오.
- 문서: GroupDocs Search Documentation
- API 레퍼런스: GroupDocs API Reference
- 다운로드: Get the latest version here
- GitHub 저장소: View on GitHub
- 무료 지원 포럼: Join the discussion
- 임시 라이선스: Acquire a temporary license here
마지막 업데이트: 2026-03-04
테스트 환경: GroupDocs.Search Java 25.4
작성자: GroupDocs