Skip to content

7.23 lou_findTable

char *lou_findTable (const char *query);

This function can be used to find a table based on metadata. query is a string in the special query syntax. It is matched against table metadata inside the tables that were previously indexed with lou_indexTables. Returns the file name of the best match. Returns NULL if the query is invalid or if no match can be found.

The match algorithm works as follows:

  • For every table a match quotient with the query is computed. The table with the highest (positive) match quotient wins. If no table has a positive quotient, there is no match.
  • A query is a list of features. Features defined first have a higher importance (have a higher impact on the final quotient) than features defined later.
  • A feature that matches a metadata field in the table (keys equal and values equal, or both values absent) adds to the quotient.
  • A feature that is undefined in the table (no field with that key) creates a medium penalty.
  • A feature that is defined in the table (one or more metadata fields with that key) but does not match (no metadata field with the right value) creates the highest penalty.
  • Every field in the table that has no corresponding feature in the query creates a very small penalty.