On 03.02.2010, at 13:54, Lukas Kahwe Smith wrote: > The issue is that I have multiple fields of data (names, address etc) that > should all be relevant for the auto suggest. Furthermore a "phrase" entered > can either match on one field or any combination of fields. Phrase in this > context means separated by spaces or dash. For this I found the above > approach the only feasible solution.
Actually I plan to write a bigger blog post about the approach. In order to match the different fields I actually have a separate core with an index dedicated to auto suggest alone where I merge all fields together via some javascript code: function splitEntity(row) { var name = row.get('name'); var telefon = row.get('telefon'); var city = row.get('city'); var arr = new java.util.ArrayList(); arr = splitField(arr, name); arr = splitField(arr, firstname); arr = splitField(arr, city); if (telefon) { arr.add(telefon); } row.put('all', arr); row.remove('name'); row.remove('telefon'); row.remove('city'); return row; } function splitField(arr, value) { if (value) { arr.add(value); var pieces = value.toLowerCase(); arr.add(pieces); if (pieces.indexOf('-') != -1 || pieces.indexOf(' ') != -1) { value = value.replaceAll(" ", "_"); pieces = pieces.replaceAll(" ", "-"); pieces = pieces.split('-'); // TODO: generate more/all permutations? drop stop words? for (var i = 0; i < pieces.length; i++) { arr.add('{'+pieces[i]+'}'+value); } } } return arr; } This way I can then use terms for a single word entered and a facet prefix search with the last term as the prefix and the rest as the query for multi term entries into the auto suggest box. The idea is that I can then enter any part of any of the fields, but I will then be suggested the entire phrase in that field: So if I have a field: Foo Bar Ding Dong and I enter "ding" into the search box, I would get a suggestion of "Foo Bar Ding Dong" regards, Lukas Kahwe Smith m...@pooteeweet.org