Custom Search

Context

You have a complex domain model consisting of various kinds of entities related to each other.

Problem

How can you effectively navigate between domain entities by name, content or other criteria?

Forces

It can be hard to anticipate which domain entities you will need to navigate to.

Designing a good query interface can be a difficult task.

Solution

Add a custom search for every kind of domain entity you want to navigate to. Simply search by substring against various attributes of the domain objects. Add a separate search for each attribute type or domain object.

In the example below we can see several custom searches for page names, page content and link names within a website, by entering an arbitrary search string into the Spotter (magnifying glass icon).

As with other custom tools, one way to implement a custom search is as a method of the domain object from which the search is initiated, with a dedicated annotation.

In GT, custom searches are annotated with <gtSearch>, and triggered within multiple moldable tools, such as the inspector, the code editor, and also the notebook.

For example thes earch for pages is implemented in AWebsite>>#gtSpotterForPageNames: gtSpotterForPageNames: aSearch <gtSearch> ^ aSearch list title: 'Page names'; priority: 10; items: [ self pages items ]; itemsLimit: Float infinity; itemName: #path; sendCategory: [ :aCategory :aStep :thisSearch | self webPageGroupClass withAll: aCategory items contents ]; filterBySubstring

Consequences

You need a Moldable Tool into which you can dynamically plug custom searches. The same search interface can accommodate multiple custom searches to query different attributes of multiple domain entities.