Help > Federator > Creating Connectors > Query Translator > Complex Query Translator

Complex Query Translator

Query translator objects are used to help translate queries from Perceptive Enterprise Search syntax into a format understood by the federated system. The default translator handles simple mapping for you, it loads settings from the connector configuration file, see Simple Query Translator.

You can override certain aspects of the default query translator if the query syntax of the federated system is more complex than can be achieved using the simple mapping.

To create your own QueryTranslator, you must create a new class that extends the QueryTranslator class; you then specify your class in the constructor of the connector.

The query translator uses a recursive decent parser to walk the query text calling back into handler methods of your class. This gives you flexibility to easily make minor tweaks to the existing translator, or completely replace it with your own.

Your query translator can override any of the following handlers:

Handler

Description

GetWord

Called for each no operator

GetPhrase

Called for each phrase

GetProximity

Called to handle proximity searches such as “in the same paragraph”

GetFielded

Called to handle fielded searches such as “John IN author”

GetFilter

Called to handle filters such as “FNAMELIKE *.pdf”

GetRange

Called to handle range searches such as “GE 1000”

GetOperator

Called to handle Boolean operators such as AND, OR and NOT

 

To understand the parsing process, consider the following examples. For each query, the following methods in the query translator are called.

CAT AND DOG NOT FISH

1.       GetWord(“CAT”)

2.       GetWord(“DOG”)

3.       GetOperator(“AND”, “CAT”, “DOG”)

4.       GetWord(“FISH”)

5.       GetOperator(“NOT”, “CAT AND DOG”, “FISH”)

CAT AND (DOG OR FISH)

1.       GetWord(“CAT”)

2.       GetWord(“DOG”)

3.       GetWord(“FISH”)

4.       GetOperator(“OR”, “DOG”, “FISH”)

5.       GetOperator(“AND”, “CAT”, “DOG OR FISH”)

TAX // RATES NOT 2004

1.       GetWord(“TAX”)

2.       GetWord(“RATES”)

3.       GetProximity(“//”, “”, “TAX”,”RATES”)

4.       GetWord(“2004”)

5.       GetOperator(“NOT”, “TAX // RATES”, “2004”)

(JOHN CITIZEN IN AUTHOR) NOT (CREDIT OR PAY) AND RETIREMENT

1.       GetPhrase(“JOHN CITIZEN”)

2.       GetWord(“AUTHOR”)

3.       GetFielded(“AUTHOR”, “JOHN CITIZEN”)

4.       GetWord(“CREDIT”)

5.       GetWord(“PAY”)

6.       GetOperator(“OR”, “CREDIT”, “PAY”)

7.       GetWord(“RETIREMENT”)

8.       GetOperator(“AND”, “JOHN CITIZEN IN AUTHOR NOT CREDIT OR PAY”, “RETIREMENT”)