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

  • Home
  • SEARCH
  • 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 8536775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:44:46+00:00 2026-06-11T10:44:46+00:00

pymongo throws me an error when trying to query and element from tags db.users.find({pseudo:alucaard}).distinct(produit_up)

  • 0

pymongo throws me an error when trying to query and element from tags

db.users.find({"pseudo":"alucaard"}).distinct("produit_up")
Out[1]: 
[{u'abus': 0,
  u'avctype': u'image/jpeg',
  u'date': u'2012-09-15',
  u'description': u'le fameux portable solide',
  u'id': u'alucaard134766932677',
  u'namep': u'nokia 3310',
  u'nombre': 1,
  u'orientation': u'portrait',
  u'photo': ObjectId('5053cd4e3a5f3a0990da8a61'),
  u'prix': 1000,
  u'tags': [u'solide', u'le', u'fameux', u'portable'],
  u'vendu': False}]

list(db.users.find({"solide":{"$in":{"document_up.tags"}}}))

Traceback (most recent call last):
 File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 2746, in  run_code exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-1-8dff98261d7a>", line 1, in <module>
list(db.users.find({"solide":{"$in":{"document_up.tags"}}}))
File "C:\Python27\lib\site-packages\pymongo\cursor.py", line 778, in next
if len(self.__data) or self._refresh():
File "C:\Python27\lib\site-packages\pymongo\cursor.py", line 729, in _refresh
self.__uuid_subtype))
InvalidDocument: Cannot encode object: set(['document_up.tags'])

NB: just a trick for the pymongo users, if your users have a limited size in text, just convert it using a set, the convert the set to a list:
for example :

phrase = "hi you, how are you, am i using this"
  1. first step: remove comma or dots to avoid regular expression searchs.
  2. second, use phrase.split() to split words.
  3. add this to a set to avoid duplicate words.
  4. convert the set to a list
  5. it will be a good idea to make a dictionnary that containing some words that will be removed from the list, like “how”, “you”, “me”, … but it will make a lot of calculation.

hope this idea will help.

  • 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-11T10:44:48+00:00Added an answer on June 11, 2026 at 10:44 am

    Your query is wrong. Try something closer to:

    list(db.users.find({"document_up.tags":{"$in":["solide"]}}))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how do i sort nested documents: produits = self.db.users.find({email:email}, {produit_up:1,_id:0}).sort((produit_up.namep), pymongo.DESCENDING) this dont work!
I am using pymongo and trying to find the best way to construct classes.
I am trying to perform a regex query using PyMongo against a MongoDB server.
I've been trying to find a way to create an ISODate object whith pyMongo
I'm using pymongo and I can't figure out how to execute the mongodb interactive
How to make a selection PyMongo only unique records? >>> db.houses.find({street:{$regex: Fl, $options:i}}).count() 107
How use sql like in PyMongo? >>> db.houses.find().count() 11616 >>> db.houses.find({hid:u16999}).count() 1 >>> db.houses.find({hid:u/9/}).count()
How to find names of all collections using PyMongo and find all fields in
I am trying to run a simple connection to pymongo but it keeps returning
con = pymongo.Connection(MONGO_DOC_HOST, MONGO_DOC_PORT) db = con.testdb datasets = db.datasets for post in db.datasets.find({test_set:xyz}).sort(num_favs,pymongo.DESCENDING).limit(2):

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.