Michael
Michael

Reputation: 42050

How do "hits" impact Lucene search performance?

The search API of Lucene receives "hitsPerPage" parameter. It looks like it has significant impact on the search performance. I tried to reduce it from 100 to 10, for instance, and saw the search time decreased twice.

Is it OK? Why does it impact the search performance? Does it indicate any problem?

Upvotes: 0

Views: 120

Answers (1)

Matt Ball
Matt Ball

Reputation: 359776

hitsPerPage specifies the size of a page, so to speak. Think about it like a Google search result: you can specify the number of results (a "hit") you get on each page.

If you only want hitsPerPage hits, that's fine, but if you want more than that, you'll have to retrieve more pages.

Why it should impact the search performance?

Because Lucene can get away with doing less work (by returning fewer matcher documents) when you want smaller pages. More hits means retrieving more documents, which in turn means seeking more locations in more files.

Upvotes: 1

Related Questions