Questions? Feedback? powered by Olark live chat software
Hopp over navigasjon

Announcing New Enhancements to Azure Search Suggestions

Posted on 23 januar, 2015

Principal Program Manager, Azure Search
“Search suggestions” is the building block you use to implement auto-complete functionality in your application. In some scenarios it’s a key piece of functionality that helps users navigate what’s available before they actually execute a search request. When we first implemented search suggestions (auto-complete) in Azure Search we did it with prefix matching. For example, if a field that’s suggestions-enabled had the string “the quick brown fox jumps over the lazy dog” we would suggest this document if the partial input was “the”, “the qu”, “the quick brown fox”, etc., but we wouldn’t suggest this document if the partial input was “quick brown fox” or “lazy dog”. We’ve heard repeatedly that it didn’t meet expectations in terms suggestions results. In summary, the feedback we got was:
  1. Search suggestions queries don’t do infix matching, only prefix matching. This was by far the most common post of feedback.
  2. Suggestions were limited to 10 per result, too few for some scenarios.
  3. Suggestions were limited to 25 characters in length. In some cases people would like to go further than that.
  4. Suggestions required at least 3 characters in the input to return results.
 

Infix Matching and Fuzzy Matching

We have deployed to production an entirely new implementation of suggestions that addresses all these items. In particular it’ll do infix matching for suggestions, allowing the user to enter ‘brown fo’, and retrieve suggestions such as ‘The quick brown fox jumped…’ (matches still need to be at word boundaries, it won’t match character sequences that exist mid-term).  Fuzzy matching is enabled to allow for more flexibility for spelling mistakes. It also allows up to 100 suggestions per result, has no limit in length other than field limits and doesn’t have the 3-character minimum length. It’s still under the experimental version 2014-10-20-Preview since we’re not done getting feedback and adjusting the feature. Our previous API for suggestions was a boolean “suggestions” option in the field definition. While it was simple, it had no room to grow (e.g. there was not spot to indicate which matching strategy to use). We are augmenting the API for suggestions now so in the future we have space to add more capabilities. Indexes now have a collection of “suggesters” which have a name and a search mode (which will allow us to bring prefix-matching suggesters to the new API soon). The first suggester we’re introducing sources suggestions from fields in documents and uses infix matching. This is what a new index definition looks like including a suggester:
{

fields: [

{ "name": "id", "type": "Edm.String", "key": true },

{ "name": "title", "type": "Edm.String" }

],

suggesters: [

{ "name": "sg", "searchMode": "analyzingInfixMatching", "sourceFields": ["title"] }

]
}
To use it in suggestions requests you need to reference the suggester (always remember to URL-encode the search text):

https://mysvcname.search.windows.net/indexes/myindex/docs/suggest?api-version=2014-10-20-Preview&search=lazy+dog&suggesterName=sg

Next Steps

You can try out these new enhancements using a tutorial we recently posted on “How to Add Suggestions (auto-complete) to your Search Applications”. You can also read the documentation for suggesters that describes all the options in the 2014-10-20-Preview API documentation. Note that you need to add new fields and bind them to a new suggester or create a new index for this to work. You can’t add a suggester bound to an existing field in an existing index. If you use suggestions and have some time please give this a try. We’d love to hear your feedback! Liam Cavanagh can be contacted at his blog or through twitter.