1. A method of applying a user-defined relevance function comprising: decomposing a complex search query into a plurality of simple operations that are connected by joins, the plurality of simple operations including a simple operator that includes homogeneous logical expressions; receiving a user-defined relevance function written in a structured query language (SQL) language from a user; associating said simple operator with said user-defined relevance function to override a default relevance function previously associated with the simple operator; retrieving a matching document matching said complex search query, including using a streaming table valued function (STVF) to perform index access to produce one or more rows that match a partial query corresponding to the simple operator, the rows corresponding to documents matching the partial query; and computing a rank for said matching document, using said user-defined relevance function.