search - search a table using a fast access method.

SYNOPSYS

search tabletosearch [options] < keytable

DESCRIPTION

The search program may be used in combination with the index program to find data rows in large tables very quickly.

OPTIONS

Program Options

-i <ifile>
Read input from file instead of the standard input.
-o <ofile>
Write output to file instead of the standard output.
-h
Do not output a table header.
-j
Join the keytable rows with the matching rows in the searched table.

Search Specification Options

C2 is a column from the table to be searched. This is generally the indexed table.

C1 is a column from the table of input keys. These are the values to be searched for.

<C2>[:<C1>] Search for the exact value (string of number) given in the key column.

-C[123] <C2>[:<C1>] [<C2>[:<C1>] [<C2>[:<C1>]]]
Search for a range of values in a one, two or three dimensional Cartesian coordinate system. The dimension is specified by a 1, 2 or 3 immedietly following the 'C' option character. The units of all columns specifying the coordinates must match. If The column name in the key table (C1) is missing from the coordinate column specification the columns in each table are assumed to have the same name.
-S[12][units] <C2>[:<C1>] [<C2>[:<C1>]] <range>
Search for a range in a one or two dimensional spherical coordinate system. The dimension is specified by a 1 or 2 immedietly following the 'S' option character. A two dimensional coordinate system is the default. The units of each column in a two dimensional system may be optionally indicated by three following characters. A 'h' indicated hours, a 'd' indicated degrees and a 'r' indicated radians. The units indicated are in order, RA column, Dec column and the range value units. The default units are 'hdd'. The units specification for a one dimensional coordinate system only determines where axis wraps over to zero, no units conversion is done between the column and range values. If The column name in the key table (C1) is missing from the coordinate column specification the columns in each table are assumed to have the same name.
-V <C2> <value>
Search for an exact value (string or number).
-R <C2> <lower> <upper>
Search for a range specified by upper and lower limit values on the command line.

-Z <C2> <lower C1> <upper C1> Search for a range of values in the search column where the range is determined by lower and upper limits in the input key table. determined This option is stuck here to allows access to the "column range" search functions but it will be integrated into the -R option is a future release.

EXAMPLES

Example 1.b:

Example of primary indexing. Make a numeric primary index of file foo.


	$ index -mb -n foo.mb A

Example 2.b:

A simple search.


	$  search foo.mb A < key.mb 
	A	B
	-	-
	3	three

Example 3.b:

A simple search with multiple input keys.


	$  search foo.mb A < keys.mb | sorttable -n A 
	A	B
	-	-
	3	three
	4	four

Example 4.b:

An absolute range search.


	$  search foo.mb -R A 1 3 | sorttable -n A 
	A	B
	-	-
	1	one
	2	two
	3	three

Example 5.b:

A key column range search.


	$  search foo.mb -Z A Alo Ahi < range.mb | sorttable -n A 
	A	B
	-	-
	3	three
	4	four
	5	five
	6	six

Example 7.1.b:

Search in a cartesian coordinate system box of 500 units square.


	$  search XYcoords.h.mb -C X 500 -C Y 500 < XYrange.mb | sorttable -n X 
	Table 1:
	
	X      	Y      	Z	Data	Mag	RA       	Dec      
	-------	-------	-------	----	---	---------	---------
	3643.64	4715.83	3476.18	ObjD   	17   	 0:43:03.29	41.355919
	4365.01	4509.67	5888.78	ObjC   	18   	 0:42:31.26	41.327306

Example 7.2.b:

Search in a cartesian coordinate system circle of 500 units raduis.


	$  search XYcoords.h.mb -C2 X Y 500 < XYrange.mb | sorttable -n X 
	Table 1:
	
	X      	Y      	Z	Data	Mag	RA       	Dec      
	-------	-------	-------	----	---	---------	---------
	3643.64	4715.83	3476.18	ObjD   	17   	 0:43:03.29	41.355919
	4365.01	4509.67	5888.78	ObjC   	18   	 0:42:31.26	41.327306

Example 9.1.b:

Search in a spherical coordinate system box of 1 degree square. The units for a one dimensional spherical coordinate system should be explicitly set. The default units for the first axis in a spherical search is hours (RA). Search uses the units of a spherical axis to compute the axis wrap point.


	$  search XYcoords.d.mb -S1d RA 0.1 -S1d Dec 0.1 < XYrange.d.mb | sorttable -n X 
	Table 1:
	
	X      	Y      	Z	Data	Mag	RA       	Dec      
	-------	-------	-------	----	---	---------	---------
	3476.18	3935.77	3500.07	Obj8   	18   	10.794499	41.247551
	3992.21	3500.07	4854.75	Obj4   	18   	10.699151	41.187092
	4365.01	4509.67	5888.78	ObjC   	18   	10.630241	41.327306
	4481.68	4461.74	3143.52	ObjB   	18   	10.608678	41.320638

Example 10.1.b:

Search in a spherical coordinate system circle of 0.1 degree raduis. Here the units of RA are in hours (the default) while the units of Dec are degrees (the default). The spherical coordinate system option knows how to combine columns of a spherical system with different units.


	$  search XYcoords.h.mb -S2 RA Dec 0.1 < XYrange.mb | sorttable -n X 
	Table 1:
	
	X      	Y      	Z	Data	Mag	RA       	Dec      
	-------	-------	-------	----	---	---------	---------
	3476.18	3935.77	3500.07	Obj8   	18   	 0:43:10.68	41.247551
	3992.21	3500.07	4854.75	Obj4   	18   	 0:42:47.80	41.187092
	4365.01	4509.67	5888.78	ObjC   	18   	 0:42:31.26	41.327306
	4481.68	4461.74	3143.52	ObjB   	18   	 0:42:26.08	41.320638
	4649.83	3837.75	2301.57	Obj6   	18   	 0:42:18.65	41.233948

Example 11.b:

Search in a spherical coordinate system circle of 0.16 degree raduis. This command sets the spherical coordinates system units to degrees for each axis and the search radius. The RA, Dec and the search range will be in degrees.


	$  search XYcoords.d.mb -S2ddd RA Dec 0.16 < XYrange.d.mb | sorttable -n X 
	Table 1:
	
	X      	Y      	Z	Data	Mag	RA       	Dec      
	-------	-------	-------	----	---	---------	---------
	2875.33	3921.35	4284.41	Obj7   	22   	10.905480	41.245383
	3368.52	3523.19	4311.07	Obj5   	21   	10.814261	41.190227
	3390.06	3035.48	3476.18	Obj2   	18   	10.810160	41.122493
	3476.18	3935.77	3500.07	Obj8   	18   	10.794499	41.247551
	3643.64	4715.83	3476.18	ObjD   	17   	10.763698	41.355919
	3992.21	3500.07	4854.75	Obj4   	18   	10.699151	41.187092
	4365.01	4509.67	5888.78	ObjC   	18   	10.630241	41.327306
	4415.41	3143.52	3500.07	Obj3   	18   	10.621091	41.137559
	4481.68	4461.74	3143.52	ObjB   	18   	10.608678	41.320638
	4649.83	3837.75	2301.57	Obj6   	18   	10.577722	41.233948
	4794.99	4311.07	4284.41	ObjA   	23   	10.550777	41.299659
	4854.75	4284.41	2875.33	Obj9   	18   	10.539729	41.295943

Example 12.1.b:

Search a spherical coordinate system circle of 0.16 degrees raduis, and limit the output with an absolute range of magnitude.


	$  search XYcoords.d.mb -S2ddd RA Dec 0.16 -R Mag 18 20 < XYrange.d.mb | sorttable -n X 
	Table 1:
	
	X      	Y      	Z	Data	Mag	RA       	Dec      
	-------	-------	-------	----	---	---------	---------
	3390.06	3035.48	3476.18	Obj2   	18   	10.810160	41.122493
	3476.18	3935.77	3500.07	Obj8   	18   	10.794499	41.247551
	3992.21	3500.07	4854.75	Obj4   	18   	10.699151	41.187092
	4365.01	4509.67	5888.78	ObjC   	18   	10.630241	41.327306
	4415.41	3143.52	3500.07	Obj3   	18   	10.621091	41.137559
	4481.68	4461.74	3143.52	ObjB   	18   	10.608678	41.320638
	4649.83	3837.75	2301.57	Obj6   	18   	10.577722	41.233948
	4854.75	4284.41	2875.33	Obj9   	18   	10.539729	41.295943

Example 13.b:

Search may be used as a "fuzzy" join of two table. The -j option causes the output of both the input keyrow and all the rows that are match that row.


	$  search -j XYcoords.d.mb -S2ddd RA Dec 0.16 -R Mag 18 20 < XYrange.d.mb | sorttable -n X_2 
	X_1	Y_1	Z_1	RA_1	Dec_1	X_2	Y_2	Z_2	Data	Mag	RA_2	Dec_2
	---	---	---	----	-----	---	---	---	----	---	----	-----
	3921.35	4649.83	4649.83	10.7	41.24	3390.06	3035.48	3476.18	Obj2   	18   	10.810160	41.122493
	3921.35	4649.83	4649.83	10.7	41.24	3476.18	3935.77	3500.07	Obj8   	18   	10.794499	41.247551
	3921.35	4649.83	4649.83	10.7	41.24	3992.21	3500.07	4854.75	Obj4   	18   	10.699151	41.187092
	3921.35	4649.83	4649.83	10.7	41.24	4365.01	4509.67	5888.78	ObjC   	18   	10.630241	41.327306
	3921.35	4649.83	4649.83	10.7	41.24	4415.41	3143.52	3500.07	Obj3   	18   	10.621091	41.137559
	3921.35	4649.83	4649.83	10.7	41.24	4481.68	4461.74	3143.52	ObjB   	18   	10.608678	41.320638
	3921.35	4649.83	4649.83	10.7	41.24	4649.83	3837.75	2301.57	Obj6   	18   	10.577722	41.233948
	3921.35	4649.83	4649.83	10.7	41.24	4854.75	4284.41	2875.33	Obj9   	18   	10.539729	41.295943