Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Database Access : The CONTAINS operator : Word indexing external documents : Indexing by line
 
Indexing by line
To index a set of documents by line, you might create a table called line with three fields: document_name, line_number, and line_text. Define the primary index on document_name and a word index on line_text. Next, write a text-loading OpenEdge program that reads each document and creates a line record for each line in the document. To decrease the amount of storage required by the line table and to normalize the database, you might replace its document_name field with a document_number field, and create a document table to associate a document_name with each document_number.
When base documents change, you must update the line index. You can store a document ID as part of the record for each line. When a document changes, you can delete all lines with that document ID and reload the document.
The following program queries the line table using the word index:
DEFINE VARIABLE words AS CHARACTER NO-UNDO FORMAT "x(60)"
  LABEL "To find document lines, enter search words".

REPEAT:
  UPDATE words.
  FOR EACH line WHERE line_text CONTAINS words:
    DISPLAY line.
  END.
END.
The example prompts for a string of words, then displays each line that matches the search criteria.