Introduction
MongoDB Integration 4 Tridion-Mi4T is intent to provide the Tridion integration with MongoDB
Let's see some of the features advantages of using MongoDB
Advantages
- Schema less : MongoDB is document database in which one collection holds different different documents. Number of fields, content and size of the document can be differ from one document to another.
- Structure of a single object is clear
- Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language
Why should use MongoDB
- Document Oriented Storage : Data is stored in the form of JSON style documents
- Index on any attribute
- Replication & High Availability
- Rich Queries
Where should use MongoDB?
- Big Data
- Content Management and Delivery
- Mobile and Social Infrastructure
- User Data Management
How to Set-up and Configure Mi4T
We have five different modules in the Mi4T
- MongoDB - Setup and configuration
- Template Bulding Block:- C# TBB is used to get the component DCP in XMLformat after some changes .
- Custom Storage Extension – A JPAComponentPresentationDAO based custom storage extension to manipulate the dynamic component presentations
- MongoDBIndexService- WCFRestFul Service which get invoked by custom storage extension and take DCP as input
- MongoDBSearchService - WCFRestFul service to get the data from MongoDB and take input query in JSON format .
SETUP
Below are various setup steps
- CMS Setup
- Copy and paste the templating building block (TBB) to a location on your Tridion CM Server
- Upload MI4TIndexing.Templating.dll TBB to Tridion CMS
- Create a Component Template with following attributes
- Output Format – XML Fragment
- Add GetComponentAsXML TBB ,Publish Binaries in Package, Link Resolver and Cleanup Template
- MongoDB Setup
- You Can download the MongoDB link
- To start MongoDB
- Create folder C:/servers and copy the bin from MongoDB installed Path
- Create data/db folders in C:/servers
- Run >> mongod --dbpath c:\servers\data --port 27017
- click here now find out more on MongoDB Installation and setup
- Content Delivery Setup
- Open the cd_storage_config.xml Storage Configuration file from the /bin/config folder and add following node under the Storages section:
- <StorageBindings><Bundle src="CustomStorageDAOBundles.xml"/></StorageBindings>
- Copy and paste CustomStorageConfig.xml file to change the value of following nodes
- ServiceEndPoint - URL of the IndexService
- TemplateIdToIndex - Tcm Id Of component Template which we have created in step 1 CMS setup.
- Copy the CustomStorageDAOBundles.xml XML file in the Content Delivery /bin/config folder
- MongoDB Index Service
- Copy and paste MongoDBIndexService on your server host it in IIS
- Copy the configuration folder as well .
- You can update the log files path from Logging.config inside the configuration folder
- Update the path of configuration\logging.config file in web.config of index service
- MongoDB Search Service
- Copy and paste MongoDBIndexService on your server host it in IIS
- Copy the configuration folder as well
- Update the log files path in Logging.config inside the configuration folder
- Update the path of configuration\logging.config file in web.config of index service
- Index service support Publishing ,Re-publishing and un-publishing
- Search service will get the data in JSON format.
To test the index and search services
- Index service
- You can use fiddler for debugging
- I have created a sample schema article
- title
- description
- imageurl
- Run index service on fiddler
- http://localhost/Service1.svc/AddDocument
- Input JSON which will generated by custom storage
- {"ServicePayload":{"DCP":"<Content xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:tcm='http://www.tridion.com/ContentManager/5.0' Title='Copy of Demo Of MongoDB' Id='tcm:2073-13667'><title>Demo Of MongoDB</title><description><![CDATA[Demo of component creation in Tridion using MongoDB]]></description><imageurl>/images/demo.png</imageurl><publication Id='tcm:0-2073-1' Title='03 Content Master' /></Content>","LanguageInRequest":"en"}}
- Execute this request in Fidler and verify the results returned
- Check in mongoDB as well inside the collection\document which you have created and entered in the index service
- Result as 0 for success and 1 for failure
- {"ResponseContext":{"
EnvironmentContext":null," FaultCollection":[]}," ServicePayload":{" ErrorMessage":"","Result":0}} - Test this by publishing the Component as well
- Log File Where Response Result :0 means successfully published and data is index in MongoDB
- Search Service
- You use the fiddler for debugging
- Run the search service on fiddler
- Url:- http://localhost/SearchSvc.svc/GetContentFromMongoDB
- {"ServicePayload":{"ContentType":"Content","Filters":[{"Key":"ItemURI","Value":"tcm:2073-13667"},{"Key":"publicationID","Value":"tcm:0-2073-1"}]}
- Execute the request in fiddler and verify the results returned
- This service will get you the result based on Filters you provide and use //MAP/REDUCE
- //Map/Reducevar map ="function() {" +" for (var key in this) {" +" emit(key, { count : 1 });" +" }" +"}";var reduce ="function(key, emits) {" +" total = 0;" +" for (var i in emits) {" +" total += emits[i].count;" +" }" +" return { count : total };" +"}";
- Output will be in the JSON format
- { "_id" : ObjectId("5741539eef525465db9eb131"), "title" : "Demo Of MongoDB", "description" : "Demo of component creation in Tridion using MongoDB", "imageUrl" : "/images/demo.png", "ItemURI" :
- "tcm:2073-13667", "publicationID" : "tcm:0-2073-1" }
- You can have AND,OR and NOT as a logical operators to query the data from MongoDB
- {"ServicePayload":{"ContentType":"Content","Filters":[{"Key":"ItemURI","Value":"tcm:278-13667"},{"Key":"publicationID","Value":"tcm:0-278-1"}],"MongoDatabase":"customerDatabase","Table":"article","QueryType":"OR"}
- You can download the code here
Happy Coding & Keep Sharing !!!
No comments:
Post a Comment