query-index or key-select:

Do a search against an index.

  Return to Contents Page   Return to Knowledge Base   Return to JAC Home Page

Note that query-index and key-select are synonymous with each other. For this section of documentation we will only show query-index, but key-select can be used equally.

Called in one of the following 3 manners :

query-index {-options} filename index_name

query-index {-options} filename {IF/WITH} index_name {EQ/NE/LT/LEetc} "startpos"

query-index {-options} filename {IF/WITH} index_name {GT/GE/>/>=} "startpos" {AND} {LT/LE/</<=} "endpos"

Supported options are:

-c COUNT the records (default is to select records)
-inn Index key count restricted to approx. nn indexes
-mTYPE Match algorithm - type is:'REGEXP' or 'DEFAULT'
-rnn Record count restricted to approx. nn records

This command allows you to select or count a list of record keys.

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 surname :

jsh-> query-index CUSTOMERS surname

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 "COOP"

jsh-> QUERY-INDEX CUSTOMERS IF surname "COOP"

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-july-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 assuming the same text pattern matching as a jQL statement (e.g. use of []^... characters). For example, if you want to select all customers whose name ends in PATEL, you could do this:

jsh-> query-index CUSTOMERS IF surname 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. 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 index keys 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 restricts the number of record keys.


http://807199.827977/r5/knowledgebase/manuals/3.0/SecondaryIndexes/html/key-select.htm last modified on 06/19/09 05:29 AM