Drupal 7 Mongo Search Views - mongodb

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.

Related

Drupal7 data in Mongo Db

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

MongoDB doesn't return all fields for some collections

I recently started working on a Mongo database, and noticed while browsing through records that some collections weren't returning all their fields. Yet querying for all objects in the collection seems to return the complete data.
What can be the cause of this? My database is hosted on mLab, and I'm seeing this issue while browsing the database through their query editor and when connecting to the database using a GUI tool (such as MongoDB Compass).
Any help is appreciated!
MongoDb compass is basically used to view data in graphical form so it just shows the fields which can be viewed in graphical form.
Eg. fields like a : ["1", "4", "8"] or array of objects
cant be viewed in graphical form.
try adding limit to your request, by default is 10
Example the following operation returns at most 50 documents in the "bios" collection:
db.bios.find().limit( 50 )

Create MongoDB Dynamic view

I'm new in MongoDB, and i would like to know if there is a way to create a dynamic view inside MongoDB.
Let me be more precise :
In mongo i have a collection with financial datas, and an GUI interface wich display the datas.
But each users could reduce the datas by adding or removing columns to the grid, and filter the grid : a classic usecase.
What i would like to do, is to create a collection for each user that listen to the master table, according to the users filters: something like this :
mongo.createView(masterCollection, filters, mapReduce)
In this scenario, mongo update each view, each time a modification is done in the master collection (update, delete, insert).
I could do something like this manualy : create a table for a user, and use a tailable cursor on my master collection with the user filters and mapReduce, and the add, remove, or update the document in the user collection.
But, i have up to 100 simultaneous users, and it would open and keep alive 100 tailable cursors on the primary collection. I don't know enough mongo, but i think it's not a best practice to do something like this.
Actualy i have a thread for each user that get data for the collection, according to the user filters, every 5 secondes.
Could you please let me now if there is a native mongo way to handle this scenario or a way to create a user view in mongo.
Thank you
Starting with MongoDB v3.4 (community and enterprise edition), there is a support for creating read only views from existing collections or other views. This feature utilises MongoDB aggregation pipeline.
To create a view from the mongo shell, you could do:
db.createView(<view>, <source>, <pipeline>, <collation> )
Using your scenario above, you could create:
db.createView(<"user_view_name">, <"source_collection_name">, <"aggregation pipeline operators">)
See all the available Aggregation Pipeline Operators - i.e. not only you could filter, you could also modify the document structure.
See MongoDB Views behaviour for more information.
MongoDB Enterprise has a feature called 'Single View' which implements database views. It's more for aggregating data from multiple tables (e.g. parent/child relationships), and may be more than what you're looking for but is worth checking out. The downside, it's only available in the pricey Enterprise edition.
Check out the description here

MongoDB Schema design for Events Management System with Full Text Search

I'm designing a solution for Events Management System with Full Text Search functionality (preferably Solr).
Following are 4 major Entities/Document Types in this system:
A Venue is a place where something can occur.
A Title is a description of something that can occur.
An Event is a particular title at a particular venue, starting on a particular date and ending on a particular date.
Within an event there will be one or more EventTimes, which are the individual showing/opening times within the event.
System has 2 Data sources:
Daily data feeds from 3rd party supplier.
User Generated Content (UGC) from end user of the system
I'm considering use of MongoDB as Database for this system and Solr for Full Text Search support. I'm also considering to use Mongo Connector for keeping Data sync between MongoDB and Solr. Mongo connector require collection in MongoDB which should directly map on Solr Document to be populated from MongoDB.
In my natural design, I don't need a MongoDB collection which will hold all the attributes which needs to be searched, but due to this requirement from connector, I'm not sure how to
create this new collection?
Any advice will be much appreciated.
Solr is selected due to comprehensive search features Solr is offering e.g. Faceted Search, Filtering, Geospatial Search with support for multiple points per document and geo polygons, Powerful Extensions to the Lucene Query Language and many more.

Elasticsearch and NoSql database [duplicate]

This question already has answers here:
Elasticsearch as a database? [closed]
(4 answers)
Closed 8 years ago.
What is the use to use both ElasticSearch and a separated Nosql database ?
Can't Elasticsearch be used both as a database and for search indexing ?
Yes, you can use ElasticSearch as a data source as well as an index.
By default each document you send to the ElasticSearch system is index, and, the original document is stored as well. This means whenever you query ElasticSearch you can also retrieve the original JSON document that you indexed.
If you have large documents and you want to be able to retrieve a smaller amount of data then when you can use the mapping API to set "store" to "yes" for specific fields, and then use the "fields" key to pull out specific fields you might want.
In my system I have address autocompletion and I only fetch the address field of a property. Here is an example from my system:
_search?q=FullAddress:main&fields:FullAddress
Then when a user selects the address I pull up the entire JSON document (along with others).
Note:
You cannot do updates like you can in SQL (update all items matching a query to increase an attribute, let's say)
You can, however, add a new document and replace the existing one at the ID you want to update. Elastic search increments a _version property on each document which can be used by the developer to enforce optimistic concurrency, but it does not maintain a separate version history of each document. You can only retrieve the latest version of a document.