documentcloud / visualsearch

A Rich Search Box for Real Data
http://documentcloud.github.com/visualsearch
MIT License
1.8k stars 237 forks source link

Remove the remainder based on the optional label value. #105

Closed DracoBlue closed 10 years ago

DracoBlue commented 11 years ago

If a facet-value is given, the autocompletion failed to calculate the remainder based on the label, since the label is what the user sees while typing.

Testcase, change:

facetMatches : function(callback) {
  callback([
    'account', 'filter', 'access', 'title',
    { label: 'city',    category: 'location' },
    { label: 'address', category: 'location' },
    { label: 'country', category: 'location' },
    { label: 'state',   category: 'location' },
  ]);
}

to

facetMatches : function(callback) {
  callback([
    'account', 'filter', 'access', 'title',
    { label: 'city',    category: 'location' },
    { label: 'address', category: 'location' },
    { label: 'country', category: 'location' },
    { label: 'state',  "value":"loc.state", category: 'location' },
  ]);
}

and type "sta" (the state-facet should be autocompleted) and press enter.

Expected behaviour: Search query should be "loc.state:" Result: Search query is: "text: sta loc.state:"