Is it possible to get the textScore on mongodb MapReduce? - mongodb

If you created a textIndex on mongodb 2.6 when you find or use the pipeline aggregate framework you can get the textScore given a query with the projection:
{'$meta': "textScore"}
This allows to operate with the textScore in further operations.
Is it possible to acces such value during a map-reduce operation?

Related

Is lookup costly when performed on same collection in mongoDB

I am new to mongoDb and I am trying to implement a subquery using lookup.Can someone explain that is lookup costly when performed on same collection in mongoDB or is there some other way to achieve the results.
I tried lookup using aggregation pipeline.

how to use $lookup in mongodb change stream?

based on docs in mongoDB Change Stream Docs i can use only these operations for getting output of change stream:
$addFields
$match
$project
$replaceRoot
$replaceWith (Available starting in MongoDB 4.2)
$redact
$set (Available starting in MongoDB 4.2)
$unset (Available starting in MongoDB 4.2)
but I want to use $lookup op :(
Do you have any idea to achieve this?
The allowed operations are transformations on the change stream-produced documents. You are asking about joining other collections.
If you want to join other collections, you need to issue those queries separately from the change stream.

MongoDB: Recommended schema for search in trees

Currently I have a tree with various depth that contains user's documents.
John\folder1\sub-folder2...\document
Peter\folder1...\document
But as I can see Mongo does not support indexes in nested documents.
I tried to de-normalize my DB to User\documents with children ids. But it seems search would search whole collection, not only documents for given app-user.
should I create collection for every app user?
What is the better solution to use built in Mongo aggregation methods?
You need to use only one collection and not create collection for every user.
Using aggregation first thing you would do is a match by userId which filters all the documents by that user and then do any aggregation operations.
Aggregation in mongo is pipeline. Documents move from one operation to another.
So if you do match on userId then only those documents would be chosen and the next aggregation operation will get only those documents which matches the userId. So your aggregation is still faster.

Using MapReduce as a Stage in Mongo DB Aggregation Pipeline

I want to use Mongo DB MapReduce functionality along with Aggregation Query.
The below are the stages which I see could be part of the Aggregation pipeline.
Filter docs for which the user has access based on content in the docs and
passed security context(roles of the user)
(Using $REDACT)
Filter based on one or more criteria (Using MATCH)
Tokenize the words in returned docs based on above filtering and populate a
collection (Using MAPREDUCE) (OR) return the docs inline
Query the populated collection/returned docs inline for words based on user
criteria using like query(REGEX) and return the words along with their
locations
I able to achieve steps 1,2 and 4 in the aggregation pipeline.
I am able to achieve Stage 3, separately by using mapreduce functionality in Mongo DB.
I want to make the mapreduce operation also as a stage in the aggregation pipeline and use it to receive the filtered docs from the earlier steps and pass the processed result to next step.
The mapreduce operation is based on sample map and reduce operation. I intend to use the map , reduce and finalize functions as shared in the below stackoverflow issue.
Implement auto-complete feature using MongoDB search
My query is I do now know if we can have MapReduce operation as part of the Mongo DB aggregation pipeline and if so can we use as inline and pass it to the next stage.
I am using Spring Data Mongo DB to implement the Mongo DB aggregation solution.
If someone has implemented the same please help me on this.

MongoDB aggregation query in RapidMiner

How to do an aggregation query in MongoDB from the RapidMiner using the mongodb plugin? I've tried to google around, unfortunately with no success at all. It has a direct support for criteria and projection (using operator "Read MongoDB"), however I don't see anyhow support for the aggregation. It does have an "Execute MongoDB Command" operator, which might be capable of doing that but I can't find any extensive examples on how to use it. Eventually, if the above mentioned is not possible, do you know any other way how to do the "unwind" over the data in the RapidMiner having the mongodb collection loaded in?
The Execute MongoDB Command Operator is a wrapper for the mongoDB command db.runCommand(). If you want to continue working in RapidMiner, you can expand the collection you get as a result from the Read MongoDB and transform it into an ExampleSet with the JSON to Data Operator.