Search code examples
javasolrsearch-engine

How to manage two different entities in SOLR?


I have several different entities I want to index in SOLR, for example:

  1. users
  2. products
  3. blogs

All are completely different in schema.
All are searched for in different places in my app.
Is there a way to do it in the same core? Is it the right approach?
Is a core the conceptual equivalence of a table in a relational DB (In which case the answer is obvious).


Solution

  • Really depends on how you will search this data. The main question is: What will you search for?

    If you will search for products (i.e. the search results are products), then design the schema around products. If you search for products by users or blogs, model users/blogs as dynamic/multivalued fields.

    If you have an app that searches for products, and another app that searches for blogs, and they're completely unrelated, put them in separate cores.

    From the Solr wiki:

    The more heterogeneous (different kinds of data) you have in one field or in one index, the less useful it is.

    So don't blindly put everything in a single core. Carefully consider what your search scenarios are.