Skip to content

Command Line Quick Start

masajiro edited this page Nov 25, 2019 · 1 revision

Installation

Please download the latest version and install it as follows. The procedure below is for the zip file.

unzip NGT-x.x.x.zip
cd NGT-x.x.x
mkdir build
cd build 
cmake ..
make 
make install

Since NGT libraries and executable files are installed in /usr/local/ by default, please add the directory to the search path as follows.

export PATH="$PATH:/opt/local/bin"
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib 

NGT command line usage

The NGT command line syntax is as follows.

ngt ngt-command options arguments

When the environment variable POSIXLY_CORRECT is set on some platforms such as Cygwin or macOS, options precede ngt-command as follows.

ngt options ngt-command arguments

Index initialization and data registration

Below is an example of index initialization and data insertion as one command.

cd (NGT_TOP_DIR)
ngt create -d 128 anng ./data/sift-dataset-5k.tsv

create is an NGT command. The specified directory anng is created and initialized as an index. The ./data/sift-dataset-5k.tsv is an object file including registered objects. Each line represents each object. In this example, each object contains 128 dimensions, which is represented as 128 columns in each line. Any additional data after each object is discarded during insertion. The number of dimensions is specified with -d. Initialization and registration can be separated using append as follows.

ngt create -d 128 anng
ngt append anng ./data/sift-dataset-5k.tsv

Nearest neighbor search

Below is an example of a nearest neighbor search.

ngt search -n 5 anng ./data/sift-query-3.tsv

The ./data/sift-query-3.tsv consists of query objects in the same format as the registration object file. Since this file has three query objects, three sets of results are displayed. The number of resultant objects is specified with -n.

Query No.1
Rank	ID	Distance
1	3031	239.332
2	4079	240.002
3	3164	244.504
4	3718	246.763
5	157	  251.094
Query Time= 0.000472 (sec), 0.472 (msec)
    ...