From d41d849e0e4bade2170212d111c4666f08680117 Mon Sep 17 00:00:00 2001 From: lucasiscovici Date: Sun, 7 Jan 2024 23:34:04 +0100 Subject: [PATCH] raise exception if fts index does not exist (#776) raise exception if fts index does not exist --------- Co-authored-by: Chang She <759245+changhiskhan@users.noreply.github.com> --- python/lancedb/query.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/lancedb/query.py b/python/lancedb/query.py index 3bdc763b..dcc72c58 100644 --- a/python/lancedb/query.py +++ b/python/lancedb/query.py @@ -14,6 +14,7 @@ from __future__ import annotations from abc import ABC, abstractmethod +from pathlib import Path from typing import TYPE_CHECKING, List, Literal, Optional, Type, Union import deprecation @@ -480,6 +481,12 @@ class LanceFtsQueryBuilder(LanceQueryBuilder): # get the index path index_path = self._table._get_fts_index_path() + # check if the index exist + if not Path(index_path).exists(): + raise FileNotFoundError( + "Fts index does not exist." + f"Please first call table.create_fts_index(['']) to create the fts index." + ) # open the index index = tantivy.Index.open(index_path) # get the scores and doc ids