(this is in a Java project)
I’m using a search engine in parallel with a relational database. The main object of interest is a ‘listing’. It has approximately 5 other entities in a composition style structure. One is location, another is a complex time and date definition.
From my experience, and from research, searching is WAY faster on Solr,Lucene, Elastic SEarch than any database with full text and geographical indexes added. So, that’s why I wish to use a search engine on the data that is in the data base. Also, the search engine will contain more granular time entries than the database, more concrete vs. formualaic.
So, in reference to a design pattern: The goal is to have CRUD happen from the API to both the database contents on an entity and also on all the time and geographical permutations instantiated in the search engine index.
I have had discussions with a partner and I believe he is right when he says
To keep coupling low, that the ‘Listing’ class, (again, the top of the data hierarchy in the data), should NOT know about the search engine and NOT have static functions added to it that do search on the search engine. He stated that a ‘Chain of Responsibility’ design pattern might be appropriate way to allow the CRUD of the API to act both on the database and the search engine contents. My read on that is that’s not correct.
I have been looking on http://sourcemaking.com/design_patterns and I think that the Facade pattern, http://sourcemaking.com/design_patterns/facade, might be best. But I’d like to hear other opinions.
Thank you in advance.
PS. I am developing an osem layer (http://en.wikipedia.org/wiki/Compass_Project) capable of being injected into a Spring IOC. This layer is custom made for ElasticSearch. As of yet, it doesn’t support transactions or foreign keys (and may never do so). But it will have annotation hooks to develop those later. You may want to look at it. It’s at https://github.com/kwince/osemManager . There are currently two branches of it underway. I’ll decide which one to merger in the next week.
Facade patter is more suitable for hiding some comlicated sub-system behind a relatively simple interface.
From what I can understand you have 2 different systems and you want to send the same request to both. You need to know what’s the relationship between these 2 systems:
Hope this helps.