Drupal7 data in Mongo Db - mongodb

I am trying to sync Drupal 7 with MongoDB using MongoDB module. When I add a node, the body (Description) field is saving in MySQL. Is there any way to add node body description field in MongoDB itself .?.

Please take a look here.
You have to be sure about migrating your fields to MongoDB, to do it you have to do some configuration on /sites/default/settings.php file like in the link.
$Conf[‘field_storage_default’] = ‘mongodb_field_storage’;
Yo have to know, because of the original data "relationed", you can not build Views from MongoDB fields with default SQL Query backend, yo have to use EFQ Views

Related

Adding _cls to existing mongodb collections

I have an existing MongoDB without the _cls field in the documents.
Data will continue to enter the DB during the lifetime of the DB, data is added through Morphia which doesn't add the _cls field automatically.
It seems not the best idea to add a _cls field to Morphia Entities.
Do you have a better idea how to make the data coming from morphia better fit (have the _cls field) in mongo documents?
Edit:
*I am using flask server in python with mongoengine which require the field
I saw the solution for using #PreSave in Morphia, it is a good Idea and I will use it if another solution is not found. ** I am looking for a solution in the Python side**. you aren't always able to change the data insertion
You could use Morphia’s #PreSave annotation to ‘tweak’ the JSON document prior to it being saved to the database. You could then just inject the _cls field and value without having to declare a field in your Java class

How to handle databases or collection being created accidentally in mongoDB? [duplicate]

Is there a way to switch off the ability of mongo to sporadically create dbs and collections as soon as it sees one in a query. I run queries on the mongo console all the time and mistype a db or collection name, causing mongo to just create one. There should be a switch to have mongo only explicitly create dbs and collections. I can't find one on the docs.
To be clear, MongoDB does not auto create collections or databases on queries. For collections, they are auto created when you actually save data to them. You can test this yourself, run a query on a previously unknown collection in a database like this:
use unknowndb
db.unknowncollection.find()
show collections
No collection named "unknowncollection" shows up until you insert or save into it.
Databases are a bit more complex. A simple "use unknowndb" will not auto create the database. However, if after you do that you run something like "show collections" it will create the empty database.
I agree, an option to control this behavior would be great. Happy to vote for it if you open a Jira ticket at mongoDB.
No, implicit creation of collections and DBs is a feature of the console and may not be disabled. You might take a look at the security/authorization/role features of 2.6 and see if anything might help (although there's not something that exactly matches your request as far as I know).
I'd suggest looking through the MongoDB issues/bug/requests database system here to and optionally add the feature request if it doesn't already exist.
For people who are using Mongoose, a new database will get created automatically if your Mongoose Schema contains any form of index. This is because Mongo needs to create a database before it can insert said index.

MongoDB collection not listed in _schema

I am using MongoDB 2.6 standard. I have successfully created multiple collections, inserted data, queried data, etc. Works fine inside of the Mongo shell, as well as from NodeJS apps using MongoSkin. So far, so good. Now I need to use a third-party tool (D2RQ) to access the data. It appears that D2RQ uses the _schema collection to obtain collection names, column names, data types, and so on. D2RQ works for three of the collections because the collections are in _schema in MongoDB. A fourth collection is not in _schema and seems to be invisible. However, the fourth collection is present in MongoDB. The collection has data. I can query the collection in the Mongo shell, and from NodeJS using Mongoskin. Any idea why the collection is not appearing in _schema? Is this a MongoDB bug?
This is not a MongoDB bug. The root cause of the problem is that D2RQ uses the UnityJDBC driver to access MongoDB. There is a parameter on the JDBC connection string indicating whether or not to rebuild _schema. D2RQ does not properly pass the parameter when making the JDBC connection to MongoDB, resulting in the _schema collection being out of date on all calls after the first call. The solution has two parts:
Part one was to write a tiny NodeJS application that does nothing but force the _schema rebuild on connection. That solved my immediate issue.
Part two was to then extend the tiny NodeJS application to be a full featured export process that generates an RDF file from MongoDB. This allowed me to remove both D2RQ and the UnityJDBC driver from the solution stack.
"The most reliable component in the architecture is the one that is not present"

Create schema.xml automatically for Solr from mongodb

Is there an option to generate automatically a schema.xml for solr from mongodb? e.g each field of a document and subdocuments from a collection should by indexed and get searchable by default.
As written as in this SO answer Solr's Schemaless Mode could help you
Solr supports a Schemaless Mode. When starting Solr this way, you are initially not bound to a schema. When you give Solr a first document it will guess the appropriate field types and generate a schema that includes those field types for you. These fields are then fixed. You may still add new fields on the fly that way.
What you still need to do is to create an Import Route of some kind from your mongodb into Solr.
After googling a bit, you may stumble over the SO question - solr Data Import Handlers for MongoDB - which may help you on that part too.
Probably simpler would be to create a mongo query whose result contains all relevant information you require, save the result to json and send that to Solr's direct update handler, which can parse json.
So in short
Create a new, empty core in Schemaless Mode
Create an import of some kind that covers all entities and attributes you want
Run the import
Check if the result is as you want it to be
As long as (4) is not satisfied you may delete the core and repeat these steps.
No, MongoDB does not provide this option. You will have to create a script that maps documents to XML.

Drupal 7 Mongo Search Views

I have nodes which are attached to mongo documents.
I want to be able to do the following:
Search the node's title + description + mongo keywords (mongo has a nid field). Any node that matches any of that information is returned in the view. Is this possible with some special view hook? (I can already search the view by description)
You need to store the node title and body in the mongodb document you want to query as mongodb can't query. If you are not bound to a current structure store the keywods as a multivalue text field and use efq_views. If you can't do that, I once wrote a MongoDB Views backend, you can look at it in http://drupal.org/sandbox/chx/1261486 but it's years old. Really the only challenge is telling MongoDB about the structure of your document but if you are bound to a structure then you don't need to solve that in a generic way.
Edit: As for credible, I am (ok, was) the MongoDB Drupal module maintainer, took part of the design and the initial implementation sprint of field API, was the Drupal architect of a Top 100 website running on Drupal 7 + MongoDB.