FullTextQuery does not return any results, even though ... - what do I do?
This is a common problem for beginners and luckily there are a few simple steps which have helped to resolve many problems of this kind.
- Do you have the minimal required configuration in your hibernate settings file? For initial testing we recommend using a file based Lucene index. Hence you should have something like this in your configuration file:
# the default directory provider hibernate.search.default.directory_provider = org.hibernate.search.store.FSDirectoryProvider # the default base directory for the indecies hibernate.search.default.indexBase = /var/lucene/indexes
If you don't specify the indexBase property the index file get created in the directory your application starts from. It is probably better to set this property explicitly since this way you know where to look for the index files. Given you have these two properties in your configuration and you have at least one entity annotated with @Entity Hibernate Search will create at startup the Lucene index files in indexBase.
- Once you confirmed that you have an index directory and index files you can download Luke (http://www.getopt.org/luke/) or even start it directly via Java Web Start. Open the *.gen file in the index directory. Luke will show you the content of your index. If there are no documents in the index have another look at your indexing code.