I'm following the doctrine extension installation guide to set up slugs in mongodb documents. I'm able to do that without any problem. However, it does NOT seem to work on embedded documents. It simply does not populate the specified slug field. No error is thrown.
I'm just curious has anybody been able to generate slugs on mongodb's embedded document? If so, is there any additional settings that I need to specify? Thanks!
Turns out it wasn't the problem with DoctrineExtension. I was trying to persist the embedded document when I should be persisting the parent document. Therefore, the embedded document was never saved.
Related
I need to have a page with common settings for my web-app, and using mongodb as my database.
I am planning to just create this collection with only one document. it will always have one document.
Is there a way to create one document by default in some way? and then just edit it from UI?
Or I should create one document from UI itself and then keep editing it?
If I use config file then user won't have flexibility of changing the value as they need.
Please share if you have better suggestion.
You can certainly have a collection with a single document in it.
Is there a way to create one document by default in some way?
You can insert the document with default values, if there isn't already a document in the collection, when your application starts.
I discovered one of my mongodb documents has duplicate fields with the same key.
I also realize this is supported by mongoDB (as per MongoDB Documentation)
I'm wondering if anyone knows how to properly query to diagnose the scope of such an issue.
And if anyone has any insight into possible root causes when working in Javascript that'd be nice too.
In Zend_Service_Solr I can add or delete a record.
$solr->addDocument($document);
Is there any way that I can update a record. I couldn't find any document for that. Or is there any extension for doing the same.
In most cases updating a document in Solr is to add the same document again (with the same value for the uniqueKey field).
It's possible to perform certain updates in more recent versions of Solr, but these require all fields to be stored (so that the document can just be re-added internally) and a custom update syntax. There are also some work in progress with non-textual DocValues being updatable without having to resubmit the complete document, but this is currently not in any released version of Solr.
The best way to handle this is usually to just re-submit the document with updated values, and have a straight forward way of doing that in your application code.
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.
In the project I've been working on, I've added a new field - an embedded document. Will this addition affect data prior to the change? From what I've read this shouldn't affect prior data, and this is actually one of the benefits of using MongoDB. Its just the previous data won't have that field.
Thanks!
No it won't affect your previous documents - each document in your collection can have it's own unique fields if you want. It is up to you to handle this at application level.