Advanced autocomplete with Solr Ngrams by Peter Tyrrell.
From the post:
The following approach is a good one if you require:
- phrase suggestions, not just words
- the ability to match user input against multiple fields
- multiple fields returned
- multiple field values to make up a unique suggestion
- suggestion results collapsed (grouped) on a field or fields
- the ability to filter the query
- images with suggestions
I needed a typeahead suggestion (autocomplete) solution for a textbox that searches titles. In my case, I have a lot of magazines that are broken down so that each page is a document in the Solr index, and has metadata that describes its parentage. For example, page 1 of Dungeon Magazine 100 has a title: “Dungeon 100”; a collection; “Dungeon Magazine”; and a universe: “Dungeons and Dragons”. (Yes, all the material in my index is related to RPG in some way.) A magazine like this might consist of 70 pages or so, whereas a sourcebook like the Core Rulebook for Pathfinder, a D&D variant, boasts 578, so title suggestions have to group on title and ignore counts. Further, the Warhammer 40k game Dark Heresy also has a Core Rulebook, so title suggestions have to differentiate between them.
(…)
Topic map interfaces with autosuggest/complete could ease users into searching and authoring topic maps.