1. A method of selecting content for display on a user device via a computer network, comprising: receiving, from a content provider associated with a content item and by a data processing system having one or more processors, content selection criteria specifying types of queries that make the content item eligible to be selected for display along with search results responsive to queries matching the specified types of queries; determining, by a query reference module of the data processing system via a data structure having information about entities, a content selection criteria entity associated with the content selection criteria and one or more related entities that do not appear in the content selection criteria but are related to the content selection criteria entity in the data structure; generating, using the data structure, a content selection criteria structure that includes an entry for the content selection criteria entity, an entry for each entity related to the content selection criteria entity, and a connection between each pair of related entities in the content selection criteria structure, the generated content selection criteria structure being separate from the data structure; receiving, by the data processing system, a search query provided via a user device; determining, by the query reference module via the data structure, a search query entity, and one or more related entities that do not appear in the search query but are related, in the data structure, to the search query entity; generating a query structure that includes an entry for the search query entity, an entry for each entity related to the search query entity, and a connection between each pair of related entities in the query structure, the generated query structure being separate from the content selection criteria structure and the data structure; determining a match between the content selection criteria structure and the query structure, including matching a topology and content of the content selection criteria structure to a topology and content of the query structure; and selecting the content item as a candidate for display on the user device based on the match between the content selection criteria structure and the query structure.