1

I am working on a autocomplete, I am using a jQuery autocomplete and extracting data from wikidata api. It is working fine. I got some help from following link

https://github.com/ouisharelabs/wikidata-autocomplete

I want to modify this search bit more, Currently it is returning everything which is matching with the word like if I search for "sherlock" then it return me both book and movie. I want to categorise it by movie and books. If I want to search only movies then result should be only from movies data not from books data. Is there any way to build a query for above case. I did this with Amazone data and they have a way to request a particular data as following:

$(document).ready(function () {
        jQuery('input.autocomplete').autocomplete({
            source: function (request, response) {
                jQuery.ajax('http://completion.amazon.com/search/complete', {
                    cache: true,
                    data: {
                        client: 'amazon-search-ui',
                        mkt: 1,
                        'search-alias': 'aps',
                        'SearchIndex': 'Books',
                        q: request.term
                    },
                    error: function () {
                        response([]);
                    },
                    success: function (data) {
                        response(data[1]);
                    },
                    dataType: 'jsonp'
                });
            }
        });
    });
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<input type="text" class="autocomplete" />

0 Answers0