arXiv:2610.37256cs.DBOct 2026

Manuscript Offprint

arXiv:2610.37256

Fast Approximate Line Nearest Neighbor Search

Jiadong Xie, Jeffrey Xu Yu, Yingfan Liu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Approximate nearest neighbor (ANN) search, which retrieves vectors close to a given query vector, is a fundamental operation in vector databases. However, emerging applications, such as selecting source images for photo-based animation and video synthesis, may require matching content while allowing a query-specified aspect contrast, such as an illumination change, to vary; a single query point does not directly express this requirement. In this paper, we study approximate line nearest neighbor (LANN) search, where an infinite query line removes the distance contribution along a specified direction while database records remain points. Prior approaches focus on top-1 search only for LANN and can incur high construction costs. Converting LANN into ordinary point ANN search through dimension lifting substantially increases index construction and query costs, while direct search on a proximity graph built for ordinary point ANN search can miss distinct regions close to a line. To address these issues, we propose LinePG, which enhances an existing proximity graph with pair edges to facilitate navigation between separated near-line regions. To find these pair edges efficiently, we first generate region pairs with spatial or graph separation, and near a line. We then score edges between the selected region pairs to guide the point endpoint selections. We conduct extensive performance studies and confirm the accuracy and efficiency of LinePG in comparison with the baseline approaches.

1 Introduction

Approximate nearest neighbor (ANN) search is a fundamental operation in vector databases [34, 35, 37, 40, 41]. Given a query vector, it retrieves data vectors that are close under a specified distance. Many approaches have been proposed for this ANN query, including proximity graph methods that navigate between nearby data points [3, 11, 17–19, 23, 27, 36, 42], which are among the state-of-the-art approaches for ANN search. However, emerging applications, such as visual media creation, introduce additional requirements for query processing. Google's Picasa included a Face Movies feature based on Exploring Photobios, which selects and orders photographs of the same person to create face animations [14]. Both Runway's Gen-4 References [28] and photo-based time-lapse mining [24] need to maintain subject or scene consistency while handling illumination differences in video-creation workflows. These workflows motivate retrieving content-consistent objects despite query-specified aspect changes. For example, when assembling a same-subject, same-pose face sequence across illumination changes for video generation, a user needs images that match the subject and pose while allowing lighting conditions to change. An ordinary ANN uses a query point for search, it does not explicitly specify which aspect variation should be disregarded, and can thus favor similar lighting over the characteristics the user wishes to preserve.

Figure

Find the same subject and pose across lighting changes.

Same subject + pose

Same subject, other pose

Other subject

Figure 1: A Case Study on YaleB Dataset

A directional model of the allowed aspect change provides a way to express this retrieval requirement. Image inversion maps real images to latent representations suitable for editing [32], while latent-direction studies identify approximately linear directions for selected facial-attribute changes [29]. A similar geometric formulation arises in query-side tangent-distance methods [15, 30], where a one-parameter image transformation is locally approximated by an affine line, and similarity to a fixed database vector is measured by its minimum distance to this line. These findings motivate representing a specified aspect change by an affine line z+tuz + tu, where z is an image code, u specifies the direction, and t controls the amount of change. For retrieval, the objective is to find existing images compatible with the specified variation; we therefore consider an infinite line query z+Ruz + \mathbb{R}u, which ranks database vectors by their minimum distance to the line without fixing the amount of change t. In the illumination example, two observations of the same subject and pose under different lighting conditions provide a query-specific secant direction through the difference between their embeddings. Fig. 1 illustrates this retrieval requirement on YaleB [7, 16]. The two query images show subject22 in pose00, with illumination azimuths of −35∘-35^\circ and +35∘+35^\circ, both at an elevation of 15∘15^\circ. Using their 128-dimensional embeddings as the line endpoints, we compare exact top-5 retrieval over the same 16,126 candidate images, excluding both query images. Line retrieval returns five images matching both the query subject and pose, compared with two for either endpoint query and four for their midpoint. The line results span different lighting conditions, whereas the point-based alternatives also return images of other subjects or poses. In the figure, A/E denote illumination azimuth/elevation in degrees.

Motivated by these query requirements, in this paper, we study line nearest neighbor search. Given a dataset P⊆Rd\mathcal{P} \subseteq \mathbb{R}^d, a query is an infinite affine line L={b0+t(b1−b0):t∈R}L = \{b_0 + t(b_1 - b_0) : t \in \mathbb{R}\} through distinct endpoints b0,b1b_0, b_1. The search retrieves kk nearest data points of the query line LL, i.e., under the distance δ(p,L)=min⁡t∈R∥p−b0−t(b1−b0)∥\delta(p, L) = \min_{t \in \mathbb{R}} \|p - b_0 - t(b_1 - b_0)\|. The database continues to store one vector per record. The line specifies which component of the difference is not penalized. Due to the curse of dimensionality [10], the exact line nearest neighbor search is computationally intensive. We focus on the approximate line nearest neighbor search (LANN) in this paper, which has not been well studied. If all queries shared one direction, a fixed projection followed by ordinary point ANN would suffice. We consider varying directions and offsets, as in the endpoint-defined workloads, so one fixed projection cannot serve all queries.

In the literature, existing approaches for LANN is theoretical studies for top-1 search [2, 26]. They decompose vector data into dense near-line groups and a sparse residual set, but literal group construction is expensive, higher than quadratic in dataset size. Alternatively, existing point-to-hyperplane nearest neighbor search [9] provides an insight to solve LANN problem by lifting the vector dimension, and then converts the query into a point query in a higher-dimensional Euclidean space. However, we prove that the lowest dimension we need for LANN problem to solve in such a way is Θ(d2)\Theta(d^{2}), which significantly increases the index construction and search cost due to the much larger dimension distance computation that is needed. Another idea is to reuse a proximity graph built for point ANN search and replace its point-to-point comparisons with point-to-line distances. The difficulty is that points close to one line need not be close to each other. They can occupy several regions separated along the line, while paths between those regions pass through points farther from the line. Hence, a search may find enough candidates in one region and stop before entering another region with better results.

In this paper, we propose LinePG, which constructs a line-enhanced proximity graph from an existing proximity graph built for point ANN search. The main contributions of this work are summarized below. ① We analyze why existing point-search structures can miss multiple near-line regions, motivating pair edges that connect separated regions close to a common line. These edges are used to enhance the original proximity graph to facilitate navigation between separated near-line regions. ② To find these pair edges efficiently and avoid examining all point pairs, we propose first finding promising pairs of regions. We introduce a balanced hierarchy that considers both vector locations and proximity graph connections to find spatially separated candidate regions, together with a quotient graph that identifies region pairs without short connecting paths. Next, a geometric score combines separation with support near a representative line to rank candidate region pairs. ③ We propose an edge-scoring mechanism to select pair edges, turning these region pairs into useful edges in the graph for navigation without increasing the total degree limit. It selects endpoints whose connecting direction is supported by multiple points in the target region and discourages directions redundant with existing or previously selected edges. The selected pair edges enhance the proximity graph, replacing retained original edges only when necessary to satisfy the total degree limit. ④ We further design a search algorithm for the line-enhanced proximity graph that uses selected pair edges as additional entrances into promising regions while avoiding redundant entrances into regions already being explored. ⑤ Experiments on six real-world datasets show that LinePG achieves 1.44–4.23x QPS of direct search on the original proximity graph when both methods reach at least 99% recall. On other datasets, LinePG can reach higher recall than 99%, while direct search can not. Compared with dimension lifting and existing theoretical methods, LinePG achieves QPS speedups of up to 976.17x and 1,665.63x, respectively, with much smaller index cost, at 100% recall on the N = 512 subsets.

The paper is organized as follows. Sections 2 and 3 define the problem and discuss existing approaches. Section 4 presents our design. Sections 5 and 6 give the region construction and candidate region pair selection algorithms. Section 7 describes search, followed by experiments in Section 8. Section 9 concludes this work.