Autocomplete accross multiple words?

I’m trying to build an autocomplete feature using manticore and have the following issue using the “CALL KEYWORDS” approach found in the documentation. In the database are cars and car parts, for example “Mini Cooper” and “BMW 326”.

  • The first word works fine and is usable that way
  • The second word does not seem consider the first word in any was
    • If the first word is “BMW” I will still get the suggestion “Cooper”: CALL KEYWORDS(‘BMW C*’, ‘myindex’, ‘hits’ as sort_mode)
    • If the first word is “Mini” I will still get the suggestion “326”: CALL KEYWORDS(‘Mini 3*’, ‘myindex’, ‘hits’ as sort_mode)

Obviously when using one of the two autocomplete results (“BMW Cooper” or “Mini 326”) the user will get no result at all, which makes those autocomplete suggestions very confusing. Why suggest a search term that will not give any results? That’s pretty much useless for anything beyond the fist word.

Is there any way to get the desired behavior: suggest the next word only using documents that include the previous word(s)?

Doesn’t seem to be natively supported.

The is a little documented bigrams indexing mode, but couldn’t figure out to make it work with CALL KEYWORDS and/or CALL SUGGEST.

I ended up just creating a index with all the two words wanted, using a underscore in place of space, so two words stay together

Thanks for the reply. Temporarily I went for a bit messy workaround by validating that the suggested search words will result in at least one matching document. With the current volume this is no performance issue at all for the project, but further optimizations might be:

  • Cache those checks using redis or something similiar to reduce the load
  • Optimize subsequent checks (get all document ids for the first word then query if at least one of those mach subsequent words)
  • Prevent multi-word suggestions if the first word results in too many hits (so the multiple subsequent query would produce too much load)

Any further suggestions would be welcome.

Ah sounds very similar to something I requested here (ie checking if they are matching documents for the two words!)