diff --git a/app/Http/Controllers/Api/ImageAnnotationController.php b/app/Http/Controllers/Api/ImageAnnotationController.php index 75dc73614..6adec7c1b 100644 --- a/app/Http/Controllers/Api/ImageAnnotationController.php +++ b/app/Http/Controllers/Api/ImageAnnotationController.php @@ -437,10 +437,6 @@ protected function performVectorSearch($featureVector, $trees, $topNLabels) */ protected function performAnnSearch($featureVector, $trees) { - // check if the HNSW index exists - if (!$this->indexExists(config('labelbot.HNSW_ImgAnno_index_name'))) { - return []; - } // Size of the dynamic candidate list during the search process. // K is always bounded by this value so we set it to K. $k = config('labelbot.K'); @@ -498,25 +494,12 @@ protected function performKnnSearch($featureVector, $trees) return $topNLabels; } - /** - * Check if the index exists. - * - * @param string $indexName The index name. - * - * @return boolean - */ - protected function indexExists($indexName) - { - return !empty(DB::select("SELECT indexname FROM pg_indexes WHERE indexname = '$indexName'")); - } - /** * Drop the HNSW index if exists. This step is necessary to perform exact KNN search * because the planner almost always prioritize the HNSW index to perform vector search. */ protected function dropHNSWIndex() { - $indexName = config('labelbot.HNSW_ImgAnno_index_name'); - DB::statement("DROP INDEX IF EXISTS $indexName"); + DB::statement("DROP INDEX IF EXISTS image_annotation_label_feature_vectors_vector_idx"); } } diff --git a/config/labelbot.php b/config/labelbot.php index 7597e4b04..63d489e44 100644 --- a/config/labelbot.php +++ b/config/labelbot.php @@ -25,27 +25,4 @@ | and returned. */ 'N' => 3, - - /* - |-------------------------------------------------------------------------- - | HNSW Index name (Image Annotation) - |-------------------------------------------------------------------------- - | - | This is the name used when creating, dropping or checking the HNSW index. - | The HNSW index is built on the vector column in the - | image_annotation_label_feature_vectors table. - */ - 'HNSW_ImgAnno_index_name' => 'image_annotation_label_feature_vectors_vector_idx', - - /* - |-------------------------------------------------------------------------- - | B-Tree Index name (Image Annotation) - |-------------------------------------------------------------------------- - | - | This is the name used when creating, dropping or checking the B-Tree index. - | The B-Tree index is built on the label_tree_id column in the - | image_annotation_label_feature_vectors table. - */ - 'B_Tree_ImgAnno_index_name' => 'image_annotation_label_feature_vectors_label_tree_id_index', - ];