1. A method comprising: identifying, by a device, a term of a filter, the term including information identifying a network address; expanding, by the device, the term into a set of sub-terms, the set of sub-terms being a logical expression of the term based on a logical OR condition; generating, by the device, an entry, of content-addressable memory, for a sub-term of the set of sub-terms, the sub-term including information identifying the network address; appending, by the device, a rule extension to the entry, the rule extension including first numerical information and second numerical information, the first numerical information being a first numerical value that corresponds to the term and indicates a priority of the term relative to another term, and the second numerical information being a second numerical value that corresponds to the sub-term and indicates a priority of the sub-term relative to another sub-term of the set of sub-terms; updating, by the device and based on the rule extension appended to the entry, the content-addressable memory in a manner that preserves a spatial ordering of the filter; and performing, by the device, an action on a packet, received via a network, using filtering rules implemented in the content-addressable memory.