Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9218123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:47:27+00:00 2026-06-18T02:47:27+00:00

I am trying to achieve something that has proven rather hard with MongoDB. I

  • 0

I am trying to achieve something that has proven rather hard with MongoDB.

I have 2 collections. One is called “marker”, the other called “routes” and holds routes that users have created between markers. The route collection has two important fields: [start_marker] and [end_marker]. Those fields are the _ids of the markers in the marker collection.

When browsing a map the app makes a geospatial box query to the marker collection to find and display markers on the map.

When a user clicks a marker a bubble shows the marker name.

Below the name there is also a dynamic field that I am having issues with. This field is supposed to show:

  • What markers were driven to from the selected marker on the map
  • How many times those markers were driven to
  • Only the 3 most frequently driven to markers will be shown in the dynamic field

Since my record collection has the [start_marker] and [end_marker] _ids recorded, I query the record collection for the selected marker’s _id in the [start_marker] field.

This yields a few hundred documents where the selected marker is always in the [start_marker] field. Now, I want to sort which [end_markers] occur the most, count how many times they occur, pick the top 3, take their _ids and query the marker collection with them to extract the marker names.

Problem is, count needs me to know which end marker field to count by, which in turn requires me to know how often it occurs. Catch 22.

End bubble result would look like this:

City 1

City 16 – 256 times

City 21 – 118 times

City 4 – 88 times

I am open to changing the database structure since Mongo is schemaless, maybe add a count field somewhere but I am at a complete loss at this moment. This query would occur a few hundred times per second so map reduce might have a negative impact on database performance. Some input would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:47:28+00:00Added an answer on June 18, 2026 at 2:47 am

    I believe I found a simple enough answer.

    1. Create another collection called “routes”.
    2. Add 3 fields: [start_city], [end_city], [count].
    3. When a user creates a document in the “records” collection, also create a document in the “routes” collection.
    4. Add 1 to the [count] field.
    5. Every time a new record is saved on the same route, increment another 1 to the count in the “routes” collection.
    6. When viewing a map marker, query the “routes” collection for the marker_id in the [start_marker] collection. Sort by count, limit the results to 3.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I fairly new to JQuery and perhaps trying to achieve something that might be
im trying to achieve something but i dont really know how I have set
I am trying to achieve something like this: while (ifstream has not been entirely
Im trying to achieve a design that has five columns with fluid width, but
I'm trying to do something that doesn't seem to hard, but I just can't
I have an activeX control that contains one window that has streaming video being
I'm having a great deal of difficulty trying to achieve something that should be
I'm trying to achieve something that Im not sure how to do it. I'm
I am trying to achieve something like this. The Expandable List consists of the
I am trying to achieve something in MySQL but even with all the answers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.