Reputation: 678
I need to extend the capabilities of my current application. In doing so I am looking to store a different set of records that overlap some of the existing documents but not entirely and introduce some new fields. Can a single Lucene index contain two types of records?
So example
Say I want to store two types of records Customer which would have the following fields NAME ADDRESS HAS KIDS
And Store NAME ADDRESS TYPE SIZE
So while the records have some things in common they have something that are different can they coexist in the same Lucene database. I wish to avoid having a generic record having all the fields as the amount of data going into this application will be a lot and I do not want to waste that much space. Would moving my program to interface with a SOLR backend help my situation.
Thanks in advance
Upvotes: 0
Views: 1052
Reputation: 5488
It's rather simple to put different data types into 1 Solr core.
You need to remember about having ids that are truly unique (UUID, or something like TYPE-PREFIX_YOUR-ID>), and have 1 common field of type that you can use to filter.
If you'd specify 2 handlers in solrconfig you might not even notice that you're working on cores with 2 data types (this part is optional).
Should you do that (2 data types in 1 core), depends on your use case.
Upvotes: 0
Reputation: 761
Lucene doesn't have schema, so you generally can do that. I wouldn't advise messing customers and stores together - how are you going to separate them in result set? Would you put customers and stores together into single DB table? Solr may help you in many ways. For example, you may put different types of data into different cores, thus having different schema and clean separation. several cores may coexist on single SOLR server. SOLR can also resolve many other problems for you. E.g. data partition (sharding), load balancing by adding several nodes, failover, etc.
Upvotes: 3