O'Reilly logo

Hibernate Search by Example by Steve Perkins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Placing time limits on a query

The example application we have been working with has a limited set of test data, only a dozen apps, and a handful of devices. So, as long as your computer has a reasonable amount of processor and memory resources, the search queries should run almost instantaneously.

However, an application with real data might involve searching across millions of entities, and there may be a risk of your queries taking too long. As a matter of user experience if nothing else, you will probably want to limit the execution of your queries to some reasonable period of time.

Hibernate Search offers two approaches for time boxing a query. One is through the FullTextQuery object's limitExecutionTime method:

... hibernateQuery.limitExecutionTimeTo(2, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required