2023-12-11 11:53:27 +00:00
|
|
|
import datetime
|
|
|
|
from enum import Enum
|
2024-06-09 23:00:39 +00:00
|
|
|
from typing import Any, Optional, Sequence, TypeVar, Union
|
2023-12-11 11:53:27 +00:00
|
|
|
|
2023-12-09 13:23:55 +00:00
|
|
|
class Schema:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SchemaBuilder:
|
2023-12-11 11:53:27 +00:00
|
|
|
@staticmethod
|
|
|
|
def is_valid_field_name(name: str) -> bool:
|
|
|
|
pass
|
|
|
|
|
2023-12-09 13:23:55 +00:00
|
|
|
def add_text_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
tokenizer_name: str = "default",
|
|
|
|
index_option: str = "position",
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_integer_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
indexed: bool = False,
|
|
|
|
fast: bool = False,
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_float_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
indexed: bool = False,
|
|
|
|
fast: bool = False,
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_unsigned_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
indexed: bool = False,
|
|
|
|
fast: bool = False,
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_boolean_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
indexed: bool = False,
|
|
|
|
fast: bool = False,
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_date_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
indexed: bool = False,
|
|
|
|
fast: bool = False,
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_json_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
tokenizer_name: str = "default",
|
|
|
|
index_option: str = "position",
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_facet_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_bytes_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
indexed: bool = False,
|
|
|
|
fast: bool = False,
|
|
|
|
index_option: str = "position",
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_ip_addr_field(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
stored: bool = False,
|
|
|
|
indexed: bool = False,
|
|
|
|
fast: bool = False,
|
2023-12-09 13:23:55 +00:00
|
|
|
) -> SchemaBuilder:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def build(self) -> Schema:
|
2023-12-11 11:53:27 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
class Facet:
|
|
|
|
@staticmethod
|
|
|
|
def from_encoded(encoded_bytes: bytes) -> Facet:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def root(cls) -> Facet:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_string(cls, facet_string: str) -> Facet:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_root(self) -> bool:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def is_prefix_of(self, other: Facet) -> bool:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def to_path(self) -> list[str]:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def to_path_str(self) -> str:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Document:
|
|
|
|
def __new__(cls, **kwargs) -> Document:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def extend(self, py_dict: dict, schema: Optional[Schema]) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@staticmethod
|
2024-09-05 14:28:35 +00:00
|
|
|
def from_dict(py_dict: dict, schema: Optional[Schema] = None) -> Document:
|
2023-12-11 11:53:27 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
def to_dict(self) -> Any:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_text(self, field_name: str, text: str) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_unsigned(self, field_name: str, value: int) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_integer(self, field_name: str, value: int) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_float(self, field_name: str, value: float) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_boolean(self, field_name: str, value: bool) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_date(self, field_name: str, value: datetime.datetime) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_facet(self, field_name: str, facet: Facet) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_bytes(self, field_name: str, bytes: bytes) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_json(self, field_name: str, value: Any) -> None:
|
|
|
|
pass
|
|
|
|
|
2024-06-09 23:00:39 +00:00
|
|
|
def add_ip_addr(self, field_name: str, ip_addr: str) -> None:
|
|
|
|
pass
|
|
|
|
|
2023-12-11 11:53:27 +00:00
|
|
|
@property
|
|
|
|
def num_fields(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_empty(self) -> bool:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_first(self, field_name: str) -> Optional[Any]:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_all(self, field_name: str) -> list[Any]:
|
|
|
|
pass
|
|
|
|
|
2024-04-22 23:27:51 +00:00
|
|
|
class Occur(Enum):
|
|
|
|
Must = 1
|
|
|
|
Should = 2
|
|
|
|
MustNot = 3
|
2023-12-11 11:53:27 +00:00
|
|
|
|
2024-06-09 23:00:39 +00:00
|
|
|
class FieldType(Enum):
|
|
|
|
Text = 1
|
|
|
|
Unsigned = 2
|
|
|
|
Integer = 3
|
|
|
|
Float = 4
|
|
|
|
Boolean = 5
|
|
|
|
Date = 6
|
|
|
|
Facet = 7
|
|
|
|
Bytes = 8
|
|
|
|
Json = 9
|
|
|
|
IpAddr = 10
|
|
|
|
|
|
|
|
_RangeType = TypeVar("_RangeType", bound=int | float | datetime.datetime | bool | str | bytes)
|
|
|
|
|
2023-12-11 11:53:27 +00:00
|
|
|
class Query:
|
2023-12-20 09:40:50 +00:00
|
|
|
@staticmethod
|
2024-04-25 02:57:09 +00:00
|
|
|
def term_query(
|
|
|
|
schema: Schema,
|
|
|
|
field_name: str,
|
|
|
|
field_value: Any,
|
|
|
|
index_option: str = "position",
|
|
|
|
) -> Query:
|
2023-12-20 09:40:50 +00:00
|
|
|
pass
|
2023-12-11 11:53:27 +00:00
|
|
|
|
2024-04-26 11:21:46 +00:00
|
|
|
@staticmethod
|
|
|
|
def term_set_query(schema: Schema, field_name: str, field_values: Sequence[Any]) -> Query:
|
|
|
|
pass
|
|
|
|
|
2024-03-31 11:56:22 +00:00
|
|
|
@staticmethod
|
|
|
|
def all_query() -> Query:
|
|
|
|
pass
|
|
|
|
|
2024-05-03 21:35:44 +00:00
|
|
|
@staticmethod
|
|
|
|
def fuzzy_term_query(
|
|
|
|
schema: Schema,
|
|
|
|
field_name: str,
|
|
|
|
text: str,
|
|
|
|
distance: int = 1,
|
|
|
|
transposition_cost_one: bool = True,
|
|
|
|
prefix=False,
|
|
|
|
) -> Query:
|
|
|
|
pass
|
|
|
|
|
2024-04-13 09:14:56 +00:00
|
|
|
@staticmethod
|
2024-05-03 20:10:58 +00:00
|
|
|
def phrase_query(schema: Schema, field_name: str, words: list[Union[str, tuple[int, str]]], slop: int = 0) -> Query:
|
2024-04-13 09:14:56 +00:00
|
|
|
pass
|
2024-04-25 02:57:09 +00:00
|
|
|
|
2024-05-03 20:10:58 +00:00
|
|
|
|
2024-04-22 23:27:51 +00:00
|
|
|
@staticmethod
|
|
|
|
def boolean_query(subqueries: Sequence[tuple[Occur, Query]]) -> Query:
|
|
|
|
pass
|
2023-12-11 11:53:27 +00:00
|
|
|
|
2024-04-24 12:12:24 +00:00
|
|
|
@staticmethod
|
|
|
|
def disjunction_max_query(subqueries: Sequence[Query], tie_breaker: Optional[float] = None) -> Query:
|
|
|
|
pass
|
2024-04-24 21:57:16 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def boost_query(query: Query, boost: float) -> Query:
|
|
|
|
pass
|
2024-04-24 12:12:24 +00:00
|
|
|
|
|
|
|
|
2024-04-25 02:57:09 +00:00
|
|
|
@staticmethod
|
|
|
|
def regex_query(schema: Schema, field_name: str, regex_pattern: str) -> Query:
|
|
|
|
pass
|
|
|
|
|
2024-05-03 20:15:21 +00:00
|
|
|
@staticmethod
|
|
|
|
def more_like_this_query(
|
|
|
|
doc_address: DocAddress,
|
|
|
|
min_doc_frequency: Optional[int] = 5,
|
|
|
|
max_doc_frequency: Optional[int] = None,
|
|
|
|
min_term_frequency: Optional[int] = 2,
|
|
|
|
max_query_terms: Optional[int] = 25,
|
|
|
|
min_word_length: Optional[int] = None,
|
|
|
|
max_word_length: Optional[int] = None,
|
|
|
|
boost_factor: Optional[float] = 1.0,
|
|
|
|
stop_words: list[str] = []
|
|
|
|
) -> Query:
|
|
|
|
pass
|
|
|
|
|
2024-04-28 10:54:21 +00:00
|
|
|
@staticmethod
|
|
|
|
def const_score_query(query: Query, score: float) -> Query:
|
|
|
|
pass
|
2024-06-09 23:00:39 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def range_query(
|
|
|
|
schema: Schema,
|
|
|
|
field_name: str,
|
|
|
|
field_type: FieldType,
|
|
|
|
lower_bound: _RangeType,
|
|
|
|
upper_bound: _RangeType,
|
|
|
|
include_lower: bool = True,
|
|
|
|
include_upper: bool = True,
|
|
|
|
) -> Query:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2023-12-11 11:53:27 +00:00
|
|
|
class Order(Enum):
|
|
|
|
Asc = 1
|
|
|
|
Desc = 2
|
|
|
|
|
|
|
|
class DocAddress:
|
|
|
|
def __new__(cls, segment_ord: int, doc: int) -> DocAddress:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def segment_ord(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def doc(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SearchResult:
|
|
|
|
@property
|
|
|
|
def hits(self) -> list[tuple[Any, DocAddress]]:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Searcher:
|
|
|
|
def search(
|
2024-04-25 02:57:09 +00:00
|
|
|
self,
|
|
|
|
query: Query,
|
|
|
|
limit: int = 10,
|
|
|
|
count: bool = True,
|
|
|
|
order_by_field: Optional[str] = None,
|
|
|
|
offset: int = 0,
|
|
|
|
order: Order = Order.Desc,
|
2023-12-11 11:53:27 +00:00
|
|
|
) -> SearchResult:
|
|
|
|
pass
|
|
|
|
|
2024-06-09 11:12:57 +00:00
|
|
|
def aggregate(
|
|
|
|
self,
|
|
|
|
search_query: Query,
|
|
|
|
agg_query: dict,
|
|
|
|
) -> dict:
|
|
|
|
pass
|
|
|
|
|
2023-12-11 11:53:27 +00:00
|
|
|
@property
|
|
|
|
def num_docs(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def num_segments(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def doc(self, doc_address: DocAddress) -> Document:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class IndexWriter:
|
|
|
|
def add_document(self, doc: Document) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_json(self, json: str) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def commit(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def rollback(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def garbage_collect_files(self) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def delete_all_documents(self) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def commit_opstamp(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def delete_documents(self, field_name: str, field_value: Any) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def wait_merging_threads(self) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Index:
|
2024-04-25 02:57:09 +00:00
|
|
|
def __new__(
|
|
|
|
cls, schema: Schema, path: Optional[str] = None, reuse: bool = True
|
|
|
|
) -> Index:
|
2023-12-11 11:53:27 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def open(path: str) -> Index:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def writer(self, heap_size: int = 128_000_000, num_threads: int = 0) -> IndexWriter:
|
|
|
|
pass
|
|
|
|
|
2024-04-25 02:57:09 +00:00
|
|
|
def config_reader(
|
|
|
|
self, reload_policy: str = "commit", num_warmers: int = 0
|
|
|
|
) -> None:
|
2023-12-11 11:53:27 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
def searcher(self) -> Searcher:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def exists(path: str) -> bool:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def schema(self) -> Schema:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def reload(self) -> None:
|
|
|
|
pass
|
|
|
|
|
2024-04-25 02:57:09 +00:00
|
|
|
def parse_query(
|
|
|
|
self, query: str, default_field_names: Optional[list[str]] = None
|
|
|
|
) -> Query:
|
2023-12-11 11:53:27 +00:00
|
|
|
pass
|
|
|
|
|
2024-04-25 02:57:09 +00:00
|
|
|
def parse_query_lenient(
|
|
|
|
self, query: str, default_field_names: Optional[list[str]] = None
|
|
|
|
) -> Query:
|
2023-12-11 11:53:27 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
class Range:
|
|
|
|
@property
|
|
|
|
def start(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def end(self) -> int:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Snippet:
|
|
|
|
def to_html(self) -> str:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def highlighted(self) -> list[Range]:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SnippetGenerator:
|
|
|
|
@staticmethod
|
|
|
|
def create(
|
2024-04-25 02:57:09 +00:00
|
|
|
searcher: Searcher, query: Query, schema: Schema, field_name: str
|
2023-12-11 11:53:27 +00:00
|
|
|
) -> SnippetGenerator:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def snippet_from_doc(self, doc: Document) -> Snippet:
|
|
|
|
pass
|
2024-08-08 10:36:04 +00:00
|
|
|
|
|
|
|
def set_max_num_chars(self, max_num_chars: int) -> None:
|
2024-09-05 14:28:35 +00:00
|
|
|
pass
|