What is OP_ELITE_SET for? How does it differ from OP_OR?

Sometimes, it is desirable to search for documents which are similar to a piece of text. One approach for doing this is to build an "OR" query from all the terms in the text, and then to perform this against a database built from the documents. However, such a query may well contain a very large number of terms, and can take quite a while to perform.

The OP_ELITE_SET operator can be used instead of OP_OR in this situation. This operator, when applied to a large number of terms, first selects the most important terms, ignores the rest, and then performs an "OR" query with just the important terms. This will often return the same, or very similar, results to a query performed with OP_OR, but will typically return the results much faster.

In general, the OP_ELITE_SET operator can be used when you have a large OR query, but it doesn't matter if the search completely ignores some of the less important terms in the query.

The number of terms which OP_ELITE_SET will use defaults to 10 (or ceil(sqrt(number_of_subqueries)) if there are more than 100 subqueries), but may be set by specifying a parameter to the query constructor. If the number of terms in the subquery is less than this value, OP_ELITE_SET will behave identically to OP_OR.

FAQ Index