QUERY-INDEX

Man Page Index


Called as:

query-index -Options filename index_name
query-index -Options filename {IF/WITH} iname {Op} "startpos"
query-index -Options filename {IF/WITH} iname {Op} "startpos" {AND} {Op} "endpos"

Where Op can be:
LT < less than
LE <= less than or equal
GT > greater than
GE >= greater than or equal.

 

Where Options can be:
Option Description
-c COUNT the records (default is to select records)
-inn Indexes used restricted to approx. nn indexes
-mTYPE Match algorithm - type is: "REGEXP" or "JQL" or "DEFAULT"
-rnn Record count restricted to approx. nn records

This command allows you to select or count a list of record keys. Note that file updates that cause a change to an index will wait for a query-index to complete. The first structure of the query-index command allows you to select all record keys sorted by the index definition. For example, to select all customers sorted by their last name:

jsh-> query-index CUSTOMERS lastname

The second structure of the query-index command allows you to specify a single conditional parameter. You can make this query less than, greater than etc. to the parameter. If you don't specify LT,GT,etc. then it defaults to equals. For example, select all customers whose name begins with "KOOP"

jsh-> QUERY-INDEX CUSTOMERS IF lastname "KOOP"

Note that in this case the double quotes will be ignored , as would single quotes. The IF token is a throwaway token, and is used simply for clarity. WITH can also be used to the same effect.

Another example is to select all customers whose date of birth is before 25 July 1956

jsh-> QUERY-INDEX CUSTOMERS WITH dob LT 25-JUL-1956

The third structure of the query-index command allows you to specify a range of values. This means the operators must be either GT or GE followed by LT or LE. If the operators are not specified the command defaults to GE and LE.

Example: Count all the customers whose last order was placed between 19-DEC-1996 and 23-DEC-1996 inclusively.

jsh--> query-index -c CUSTOMERS IF order.date >= "19-DEC-1996" and <= "23-DEC-1996"

Option -c means a count of record keys is done instead of producing a select list.

Option -m allows the pattern matching algorithm to be changed :

When the command is performing its test, it does so using a simple string or numeric test. If you want to make the test more akin to say a jQL command, then you would use the -mJQL option. For example, if you want to select all customers whose name ends in PATEL, you could do this:

jsh-> query-index -mJQL CUSTOMERS IF lastname EQ "[PATEL"

Similarly you can use the -mREGEXP to use a pattern matching algorithm called "Regular Expressions". This allows complicated patterns to be searched for. See the "Regular Expressions" chapter in this document. As an example, the following command will select all products whose description begins with the letter A is followed by any number of characters before the sequence PIPE is found:

jsh-> query-index -mREGEXP PRODUCTS IF description EQ "^A.*PIPE"

Option -i can be used to restrict the number of indexes used to create the list of record keys. This can be useful to restrict a search to a smaller subset.

Option -r is similar to -i except it restrict the number of record keys.

 

Notes:

QUERY-INDEX cannot be used against a select-list generated from a previous QUERY-INDEX.


KEY-SELECT: DO A SEARCH AGAINST AN INDEX.

This command is identical to query-index and is provided for backwards compatibility with legacy applications.


INDEXES