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”],
}
]
}