Update file_api.py
Browse files354 unmodified lines355356357358359360361362363364365255 unmodified lines621622623624625354 unmodified lines# 캐시가 비어있으면 API에서 가져오기return fetch_all_from_api(category, region, keyword)# 키워드 검색 (벡터 검색)if keyword and keyword.strip():cache = get_cache()items = cache.search(keyword.strip(), n_results=500)status = f"🔍 캐시에서 '{keyword}' 검색"# 필터 적용 (캐시 데이터에서 필터링)filtered = items255 unmodified linesexcept Exception as e:import tracebackreturn f"상세 정보 조회 실패: {str(e)}\n{traceback.format_exc()}", [], None354 unmodified lines355356357358359360361362363364365366367368369370371372373374375376377378379380381255 unmodified lines637638639640354 unmodified lines# 캐시가 비어있으면 API에서 가져오기return fetch_all_from_api(category, region, keyword)# 키워드 검색 (텍스트 매칭 - 한국어 정확도 보장)if keyword and keyword.strip():kw = keyword.strip().lower()kw_terms = [t.strip() for t in kw.replace(",", " ").split() if t.strip()]matched = []for item in items:# 검색 대상 텍스트 결합search_text = " ".join([str(item.get("title", "") or item.get("pblancNm", "") or ""),str(item.get("description", "") or item.get("bsnsSumryCn", "") or ""),str(item.get("author", "") or item.get("jrsdInsttNm", "") or ""),str(item.get("lcategory", "") or item.get("pldirSportRealmLclasCodeNm", "") or item.get("category", "") or ""),str(item.get("hashTags", "") or ""),str(item.get("trgetNm", "") or item.get("target", "") or ""),str(item.get("excInsttNm", "") or ""),]).lower()# 모든 키워드 term이 포함되어야 매칭 (AND 조건)if all(t in search_text for t in kw_terms):matched.append(item)items = matchedstatus = f"🔍 '{keyword}' 검색 ({len(items)}건 매칭)"# 필터 적용 (캐시 데이터에서 필터링)filtered = items255 unmodified linesexcept Exception as e:import tracebackreturn f"상세 정보 조회 실패: {str(e)}\n{traceback.format_exc()}", [], None
file_api.py+21-6