0

I'm new to MeiliSearch and trying to set up a simple demo. It is very similar to this official demo. I'm wondering how could I change the default limit of 20 documents in the app?

ytrewq
  • 59
  • 1
  • 10

1 Answers1

1

This can be done with <ais-configure :hitsPerPage="50" />. For example:

<div class="search-panel__results">
  <ais-search-box placeholder="Search here…" autofocus/>
  <ais-hits  :transform-items="transformItems">
    <template slot="item" slot-scope="{ item }">
      <ais-configure :hitsPerPage="50" />
      <div>
        <div class="hit-info"> {{ item.year }}</div>
        <div class="hit-info">
          <ais-highlight :hit="item" attribute="firstname" />
          &nbsp;
          <ais-highlight :hit="item" attribute="surname" />
        </div>
        <div class="hit-info motivation">
          <ais-highlight :hit="item" attribute="motivation" />
        </div>
      </div>
    </template>
  </ais-hits>
  <ais-pagination />
</div>

To change the default pagination limit off 200 hits, in the App.vue file (from the referenced official demo) update the data section to the following (setting paginationTotalHits to the number you want):

data() {
  return {
    searchClient: instantMeiliSearch(
      MEILISEARCH_HOST,
      MEILISEARCH_API_KEY,
      {
        paginationTotalHits: 300, // default: 200.
      }
    ),
  };
},
paul41
  • 576
  • 7
  • 17
  • Sorry, there seems to be a limit of 200 hits in total. Is there a way to change it too? – ytrewq Jun 06 '21 at 10:45
  • Did you get an error when you went over 200? I just tested 500 and it worked. A word of caution with that though, it was so much data it crashed my browser. – paul41 Jun 06 '21 at 13:37
  • I’ve noticed the same in the MeiliSearch x MoMA demo ([site](https://moma.meilisearch.com), [GitHub](https://github.com/meilisearch/demo-MoMA)): after 200 results the “Show more” button gets disabled. I’ve also tried to get 500 hits at once, I can get only 200. But no error. – ytrewq Jun 06 '21 at 14:55
  • [This](https://stackoverflow.com/questions/67297905/instantsearch-js-custom-widget-increase-returned-results) seems to be related, although I couldn't find an issue – ytrewq Jun 06 '21 at 15:13
  • This is interesting. I see what you are referring to, but at least so far I haven't found anywhere in either the documentation or source code itself that limits things to 200. – paul41 Jun 06 '21 at 16:04
  • I figured out where the limit is happening and updated the answer. Note that in the MoMA demo you referenced, that one is not using pagination so the answer would be slightly different. – paul41 Jun 06 '21 at 17:26