0

I'm getting an error using the searchBox widget from Algolia instantsearch.js The error message reads:

indexName is not valid

This error is weird, because not only does it exist, but it's displaying results! The problem repeats each time I type something into the searchBox widget, and the results are not filtered by whatever I type. I've created a plunker to see if anyone can tell me what I'm doing wrong.

http://plnkr.co/edit/ihz5VMZ6HUDaYKTqwo9V?p=preview

<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" href="//cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.css">
<script src="//cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js"></script>
</head>

<body>


      <input type="text" id="search-box" class="form-control">
<table class="table table-striped">
            <thead>
                <tr>
                    <th>Number</th>
                    <th>Name</th>
                    <th>Starts</th>
                    <th>Duration</th>
                    <th>Room</th>
                    <th><span class="glyphicon glyphicon-info-sign"></span></th>
                </tr>
            </thead>
            <tbody id="hits-container">
            </tbody>
</table>
<div id="pagination-container"></div>


<script>


var search = instantsearch({
  appId: '5V0BUFDX8J',
  apiKey: 'a25692c12853aea7a77c5a7125498512',
  indexName: 'C86FE050-6C48-11E5-84AA-BA5F164D0BA4_events',
  urlSync: true
});

search.addWidget(
instantsearch.widgets.searchBox({
  container: '#search-box',
  autofocus: true,
  placeholder: 'Search for events by keyword, description, or event number.'
})
);

search.addWidget(
    instantsearch.widgets.hits({
      container: '#hits-container',
      templates: {
        empty: 'No events found',
        item: '<tr><td><a href="{{view_uri}}">{{event_number}}</a></td><td><a href="{{view_uri}}" target="_new">{{name}}</a></td><td>{{startdaypart_name}}</td><td>{{duration_name}}</td><td>{{room_name}}</td><td><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" title="{{description}}"></span></td></tr>'
      },
    })
  );

  search.addWidget(
    instantsearch.widgets.pagination({
      container: '#pagination-container'
    })
  );

  search.start();

</script>

  </body>

</html>
4

1 に答える 1