I've skimmed the docs for the Java version of Lucene, but I can't really see the top-level "this is how it works" info so far (I'm aware I need to RTFM, I just can't see the wood for the trees).
I understand Lucene uses search indexes to return results. As far as I know, it only returns "hits" from those indexes. If I haven't added an item of data when building the index then it won't be returned.
That's fine, so now I want to check the following assumption:
Q: Does that mean that any data I want displayed on a search page needs to be added to the Lucene index?
I.e.
If I want to search for Product
s by things like sku, description, category name, etc, but I also want to display the Customer
they belong to in search results, do I:
- Make sure the Lucene index has the denormalised
Customer
's name in the index. - Use the hits returned by Lucene to somehow query the database for the actual product records and use a
JOIN
to get theCustomer
's name.
I assume it's option 1, since I'm assuming there's no way to "join" the results of a Lucene query to an RDBMS, but wanted to ask it my assumptions about the general usage are correct.