The correct way to limit results in jquery ui autocomplete with map
<p>What is the correct way to limit results of ui.autocomplete when used with map?</p>

<p>I found similar issue with solution which works for simple array here: <a href="http://stackoverflow.com/questions/7617373/limit-results-in-jquery-ui-autocomplete">limit results in jquery ui autocomplete</a>
But my array is a bit nested, apart from the fact that the source is external.</p>

<p>I have also tested another solution here to undefined error: <a href="http://stackoverflow.com/questions/8921269/jquery-autocomplete-limit-results">jquery autocomplete limit results</a></p>

<p>Below is what I adapted from the link, but to no success.</p>

<p><strong>My test:</strong></p>

<pre><code>var sourceUrl = '/path/to/products.json';
$("#auto").autocomplete({
        source: function (request, response) {        
          $.getJSON(sourceUrl, {term: request.term}, function (result) {
                response($.map(result.products, function (item) {
                   var myarray = item.product;
                   console.log(myarray); // the returns look expected (Product One, Product Two, etc)
                   var results = $.ui.autocomplete.filter(myarray, request.term);
                   results.slice(0, 10);
                }));                
          });
        }
}); 
</code></pre>

<p><strong>products.json:</strong></p>

<pre><code>{"products": [{"label": "Product One", "product": "Product One", "sku": "12345"},    ...
</code></pre>

<p>It will be easier to simply output all the products, but they are are just to many/heavy to hold in dropdowns. Thats why I need to limit the result.</p>

<p>Any hint is very much appreciated. Thanks.</p>
