Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
how do I access a specific field in a compound index using mongo db?

I am using pymongo to query my database to get back results for my API. As of now, I have a compound index to perform string searching:

diseases_collection.create_index([('url', pymongo.TEXT), ('headline', pymongo.TEXT), ('main_text', pymongo.TEXT), ('reports', pymongo.TEXT), ('diseases', pymongo.TEXT), ('syndromes', pymongo.TEXT), 
('event_reports', pymongo.TEXT)])

However, I want a way to search for geographical locations in the reports field only, and not the other fields. How can I do this? Each document has the following structure (obviously different values):

{ 
url: “http://outbreaks.globalincidentmap.com/eventdetail.php?ID=8237”, 
date_of_publication: “2011-02-22 12:29:00”, 
headline: “AUSTRALIA :: Anthrax scare closes Penrith tax office”, 
main_text: “[PenrithStar.com.au]  AUSTRALIA :: Anthrax scare closes Penrith tax office
At about 11.40am, a worker discovered some white powder, believed to have been part of a mail delivery.", 
 reports: [
   {
    diseases: “Anthrax”,
    syndromes: [],
    event_date: “2011-02-22 11:40:00”,
    locations: [“Sydney”, “Penrith”],
    event_reports:[“hospitalised”],
   }
 ] 
}

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

A collection can have at most one text index. When you specify multiple fields to be text indexed, they all are merged into one index.

Therefore you cannot query this index by values of only some of the fields you have indexed.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda