File size: 1,085 Bytes
19de729
bfcc872
 
19de729
bfcc872
 
 
 
 
 
 
 
 
 
 
19de729
bfcc872
 
19de729
bfcc872
 
 
 
 
19de729
bfcc872
 
 
19de729
bfcc872
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# src/analyzer/search/query.py
"""
DEPRECATED: This module has been consolidated into hybrid_index.py

For migration, use:
  - HybridIndex -> load_index() from hybrid_index
  - index.search() -> search(index, query, k=5)
  - index.by_grant_id() -> search_by_grant_id(index, grant_id)
"""
import warnings
warnings.warn(
    "query.py is deprecated. Use hybrid_index.py instead.",
    DeprecationWarning,
    stacklevel=2
)

# Keep old class as a thin wrapper for backward compatibility
from .hybrid_index import load_index, search, search_by_grant_id

class HybridIndex:
    """Deprecated wrapper. Use functions from hybrid_index directly."""
    def __init__(self, path):
        warnings.warn("HybridIndex class is deprecated", DeprecationWarning)
        self._idx = load_index(str(path))

    def search(self, query: str, limit: int = 5):
        results = search(self._idx, query, k=limit)
        return [doc for doc, score in results]

    def by_grant_id(self, gid: str):
        results = search_by_grant_id(self._idx, gid, k=10)
        return [doc for doc, score in results]