The map element

The map element defines SQL that brings in additional lexical material that is associated with values of a column. For example, below lexical material is being imported from a NickName table and associated with existing name values in the Customer table:

    <table id="Customer" writes="full" lex="customer,customers,person">
        <column id="id" type="int" properties="-superlatives,-value-stands-for-column"/>
        <column id="name" type="text">
             <map>
<![CDATA[
SELECT X.name,Y.name
FROM Customer AS X, NickName AS Y
WHERE X.id=Y.customer
]]>
             </map>
        </column>

        <primary_key key="id"/>
        <primary_value key="name" />
    </table>
    

So if 'Bob' has the nickname 'Big Bob', then users can ask questions like 'item bought by Big Bob'.

The convention is that this SQL selects first on the value of the column, and then second on the alternative lexical form that is being imported.

Maps allow for the possible integration of soundex type functions, scrambling and stemming functions from the underlying database to give more lexical matches for database values. This is yet another example of pushing C-Phrase configuration complexity onto the underlying database engine.