package com.demo.seecanalysisbackend.repository; import com.demo.seecanalysisbackend.model.LogEntry; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.elasticsearch.annotations.Query; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.stereotype.Repository; import java.time.LocalDateTime; import java.util.List; @Repository public interface LogEntryRepository extends ElasticsearchRepository { Page findByTimestampBetween(LocalDateTime startTime, LocalDateTime endTime, Pageable pageable); Page findByTimestampBetweenAndLevelIn(LocalDateTime startTime, LocalDateTime endTime, List levels, Pageable pageable); Page findByTimestampBetweenAndApplicationIn(LocalDateTime startTime, LocalDateTime endTime, List applications, Pageable pageable); List findByTimestampBetweenAndLevel(LocalDateTime startTime, LocalDateTime endTime, String level); Page findByTimestampBetweenAndBizName(LocalDateTime startTime, LocalDateTime endTime, String bizName, Pageable pageable); Page findByTimestampBetweenAndBizNameIn(LocalDateTime startTime, LocalDateTime endTime, List bizNames, Pageable pageable); @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"multi_match\": {\"query\": \"?2\", \"fields\": [\"raw_message\", \"business_info\", \"method_location\", \"service_name\", \"trace_id\", \"bizName\"]}}]}}") Page findByTimestampBetweenAndMessage(LocalDateTime startTime, LocalDateTime endTime, String message, Pageable pageable); @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"term\": {\"log_level\": \"?2\"}}]}}") long countByTimestampBetweenAndLevel(LocalDateTime startTime, LocalDateTime endTime, String level); @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}]}}") long countByTimestampBetween(LocalDateTime startTime, LocalDateTime endTime); @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"term\": {\"bizName\": \"?2\"}}]}}") long countByTimestampBetweenAndBizName(LocalDateTime startTime, LocalDateTime endTime, String bizName); @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"term\": {\"service_name\": \"?2\"}}]}}") Page findByTimestampBetweenAndServiceName(LocalDateTime startTime, LocalDateTime endTime, String serviceName, Pageable pageable); @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"term\": {\"trace_id\": \"?2\"}}]}}") Page findByTimestampBetweenAndTraceId(LocalDateTime startTime, LocalDateTime endTime, String traceId, Pageable pageable); }