Topic: Accessing Zebra directly with yaz-client

Topic type:

Kete depends on Zebra and associated libraries to provide full-text search capabilities. Occasionally, you may want to access Zebra directly using a command-line client. This is where yaz-client comes in.

Originally written by James Stradling, Kete Developer for Katipo Communications, Ltd.

Introduction

Using yaz-client to connect to a zebra instance is easy.

These instructions assume a couple of things about your environment:

  1. You're connecting to a zebra instance running on your local machine (or you're accessing the remote server directly via a secure shell such as SSH).
  2. You have yaz-client installed on your machine. yaz-client should have been installed as part of the installation is required software for kete. See the installation instructions for further details. 

Connecting to a zebra instance

 

 Launch yaz-client as follows:

$ yaz-client

A Z> prompt indicates you are in the yaz-client shell 

Set your authentication details (replace with your real username and password):

Z> authentication username/password

The username and password are the ones you configured Kete to use during the configuration of your new Kete system. You can find these the file located at /path/to/your_app/zebradb/keteaccess.

Connect to the zebra instance

The connect command for the public Zebra instance is:

Z> open tcp:localhost:9901/public

.. and for the private Zebra instance:

Z> open tcp:localhost:9902/private

You may need to change the port and hostname depending on your particular configuration.

Select format

Z> format xml

You can now run queries and commands against the Zebra instance.

When you're finished, close the connection:

Z> close

.. and quit the command-line client:

Z> quit

Running queries on Zebra via yaz-client

An example query which returns all records indexed is:

Z> find @attr 1=_ALLRECORDS @attr 2=103 ""

The number of results can be seen in the "hits" attribute returned in the search.

More information about the query syntax (PQF) can be found here: http://www.indexdata.com/search.tkl?query=pqf

Troubleshooting

Most of the errors returned by Zebra can be attributed to either:

  • Lack of records to search, or
  • Lack of records with the requested attributes to search
    I.e. if you search for a specific value on a specific attribute, and that attribute is not present in any of the records indexed by the Zebra instance, the search may fail with an error such as "Unsupported Use attribute (114) 21".

Discuss This Topic

There are 0 comments in this discussion.

join this discussion

Creative Commons Attribution-Share Alike 3.0 New Zealand License
Accessing Zebra directly with yaz-client by James Stradling is licensed under a Creative Commons Attribution-Share Alike 3.0 New Zealand License