A simple document query: Searching for one word

How to write a query that searches for one word in a word index.

Document queries are specifications for searching a document base. Queries are coded in XML using the TEXTML Query Language. Document queries can be validated against SEARCH_DOCUMENTS.DTD (a system document).

Here is a query that searches the index named "FullText" for the word "game". FullText is a word index.

<?xml version="1.0" encoding="utf-16"?>
<!-- OneWordQuery.xml -->
<query VERSION="4.5" RESULTSPACE='OneWordQuery' >
	<key NAME="FullText">
		<elem>game</elem>
	</key>
</query>

You can:

  • Construct a query using any text editor, and save it as a query file (i.e., an XML file).
  • Import a query file into your program, store it in a string variable, then use the query to search a specific docbase. You can, of course, construct and run the query programmatically.
  • Construct a query using TEXTML Console, save the query with a specific docbase, and run the query against the docbase.
  • Copy query files into TEXTML Console's library of queries for a docbase (see below), then run them using TEXTML Console.

The simplest way to test a query is to run it using TEXTML Console, since no programming is involved. To search the docbase with a specified query, right-click the query, then click Run.

Here is TEXTML Console showing the results of running OneWordQuery.xml against SampleNewsDocbase, a document base generated from the sample documents and the sample indexdefinition.xml file:

Figure: TEXTML Console after searching for the word "game".


TEXTML Console showing the results of a search
Note: To display any of the documents returned by a query: in the TEXTML Search Results pane, double-click the document.

When you create a document query, you must specify the index in which to perform the search. The index is referenced by the <key> element, highlighted here:

<?xml version="1.0" encoding="utf-16"?>
<!-- OneWordQuery.xml -->
<query VERSION="4.5" RESULTSPACE='OneWordQuery' >
    <key NAME="FullText">
        <elem>game</elem>
    </key>
</query>
Note: A query does not specify the name of a document base.

Sample queries

All sample queries are located in your Program Files directory for TEXTML Server: [...]\IxiaSoft\TextmlServer[version]\SDK\Queries\. These queries are designed to be run against the SampleNewsDocbase.

To use TEXTML Console to run the sample queries, copy them to TEXTML Console's two directories of queries for the the SampleNewsDocbase.

The location of these libraries depends on your platform, your username, the name of the TEXTML Server instance, and the name of directory that contains the docbase.

In Microsoft Windows 7, document queries are here:

c:\Users\username\TextmlAdminWorkspace\TextmlAdmin\servername\docbasedirectory\Queries\.

And indexed value queries are here:

c:\Users\username\TextmlAdminWorkspace\TextmlAdmin\servername\docbasedirectory\Queries of Indexes\