MongoEngine / MongoEngine/mongoengine

item_frequencies() always returns {None: $count} on EmbeddedDocumentListField

Open
#2,389 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

Hiya!

While using item_frequencies() on an EmbeddedDocumentListField field, the return value seems to be {None: $count } in all cases. The document below is an example in the Sigma collection. Maybe I'm forgetting something or is this an unsupported feature? 🤔

Python version: Python 3.8.6
MongoEngine version: mongoengine==0.20.0

Example Document

hash:"f8127c4e4cdaa4b551195a2b13394a88b0d1e8748c587ad1e122df03e2b1120e"
date:2019-12-19T00:00:00.000+00:00
level: "high"
description:"Detects download of Ursnif malware done by dropper documents."
techniques: [
  {
     name: "Web Service",
     ...
  }
]

Command used

Sigma.objects().item_frequencies('techniques.name')

Return value

{None: 734}

Note

Running item_frequencies() on a root field such as 'level' in the document does work and returns:

# Output of Sigma.objects().item_frequencies('level')
{'critical': 143, 'high': 349, 'low': 58, 'medium': 184}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with an EmbeddedDocumentListField and item_frequencies('techniques.name'), then inspect the item_frequencies implementation and its existing tests. Done means nested fields in embedded-document lists return frequencies for their actual values instead of {None: count}, while root-field behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.