EQL filter syntax

EQL record filters are specified with WHERE clause types of Boolean expressions.

The syntax for both DataSourceFilterString and SelectionFilterString use expressions similar to those used in an EQL WHERE clause. The syntax is:
<DataSourceFilterString>WHERE booleanExpression</DataSourceFilterString>

<SelectionFilterString>WHERE booleanExpression</SelectionFilterString>

The expression uses one or more attributes whose values are to be tested, and one or more test conditions. For example, the expression can use numeric and string value comparison operators, NULL value evaluation operators, and logical operators, as listed in the following table. Note that unlike an EQL statement, the WHERE keyword is not used in the query string.

The following table lists the operators that can be used:
Operator Description Example
= Equal (tests the equality between two expressions) COUNTRY_NAME = 'France'
<> Not equal (tests the condition of two expressions not being equal to each other) PROD_WEIGHT_CLASS <> 2
> Greater than (tests the condition of one expression being greater than the other) PROD_MIN_PRICE > 1000
< Less than (tests the condition of one expression being less than the other) QUANTITY_SOLD < 500
>= Greater than or equal (tests the condition of one expression being greater than or equal to the other expression) PROD_MIN_PRICE >= 75
<= Less than or equal (tests the condition of one expression being less than or equal to the other expression) PROMO_COST <= 1500
BETWEEN low AND high Specifies an inclusive range of values. Use AND to separate the low (starting) and high (ending) values. FISCAL_YEAR BETWEEN 2000 AND 2006
IS NULL Specifies a search for NULL values. CUST_EMAIL IS NULL
IS NOT NULL Specifies a search for values that are not NULL. PROD_STATUS IS NOT NULL
AND Combines two conditions and evaluates to TRUE when both of the conditions are TRUE. PROD_MIN_PRICE > 1000 AND COUNTRY_NAME = 'Spain'
OR Combines two conditions and evaluates to TRUE when either condition is TRUE. PROD_LIST_PRICE > 50 OR PROD_CATEGORY = 'Hardware'
NOT Reverses the value of any Boolean expression. NOT(COUNTRY_REGION = 'Europe' AND AMOUNT_SOLD > 1000)

Note that you cannot use aggregating functions (such as SUM) in the query. The IN expression is also not supported.

Using single quotes with string values

When using string value comparison operators, make sure that you use single quotes around the text value field. For example, if the COUNTRY_NAME standard attribute is of type mdex:string, then the usage would be:
COUNTRY_NAME = 'Spain'  // Correct

COUNTRY_NAME = "Spain"  // Incorrect because double quotes are not allowed

COUNTRY_NAME = Spain  // Incorrect because the attribute stores string values
When using numeric value comparison operators, do not use quotes of any kind around the value field. For example, if the AMOUNT_SOLD standard attribute is of type mdex:double, then the usage would be:
AMOUNT_SOLD = 500  // Correct

AMOUNT_SOLD = "500"  // Incorrect because the attribute stores numeric values

Escaping special XML characters

If you are making direct queries against the Conversation Web Service (for example, by using the soapUI tool), you may need to escape some XML characters to prevent parsing errors. For example, you should use the &lt; escape character instead of the < (less than) character. Note that examples in this chapter will use the unescaped version for ease of reading.

Setting a language ID for parsing error messages

The Request complex type has an optional Language element that sets the language for error messages that result from EQL parsing. The supported languages and their corresponding language IDs are:
  • Chinese (simplified): zh_CN
  • Chinese (traditional): zh_TW
  • English: en
  • French: fr
  • German: de
  • Italian: it
  • Japanese: ja
  • Korean : ko
  • Portuguese: pt
  • Spanish: es

If a language ID is not specified, then en (English) is the default.

Note that this Language element serves a different purpose from the Language attribute in the SearchFilter type (for record search) and the ValueSearchConfig type (for value search).

The following example shows where in the request you would specify the Language element for EQL parsing error messages.

Example

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <Request xmlns="http://www.endeca.com/MDEX/conversation/2/0">
        <Language>fr</Language>
        <State>
          <DataSourceFilterString>
            COUNTRY_NAME = 'France'
          </DataSourceFilterString>
          <SelectionFilterString>
            AMOUNT_SOLD > 1000
          </SelectionFilterString>
        </State>
        <ContentElementConfig xsi:type="RecordListConfig"
          HandlerFunction="RecordListHandler"
          HandlerNamespace="http://www.endeca.com/MDEX/conversation/handlers/2010"
          Id="RecordList" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        </ContentElementConfig>
       </Request>
    </soapenv:Body>
</soapenv:Envelope>

In this example, the DataSourceFilterString first filters out all records that do not have a value of "France" in their COUNTRY_NAME assignment. It then returns all records that have an AMOUNT_SOLD assignment with a value greater than 1000.