LIKE Запрос в пн go дБ для встраиваемых объектов Python - PullRequest
0 голосов
/ 02 февраля 2020

Я очень плохо знаком с понедельником go или любым другим запросом к базе данных. Пожалуйста, помогите мне написать 2 запроса.

  1. Мне нужно сделать flask API, забыв все рецепты из названий ингредиентов. {Поскольку я буду запрашивать "чечевицу, масло"}, она должна вернуть мне список рецептов, в которых ингредиенты содержат чечевицу и масло, сейчас я должен поставить точное ключевое слово для ниже, но мне нужен запрос, чтобы, если я буду искать чечевица должна возвращать то же самое.

    db.collection.find({"ingredients.type": {$in: ["cup lentils"]}})

  2. Получение всего списка ингредиентов .ingr из таблицы ниже. для каждого рецепта (чашка чечевицы, растительное масло, ...) и весь рецепт [все рецепты объединены ингредиенты. Только Python Запрос Пожалуйста.

    Пример данных:

    {
        "category": "Indian",
        "recipe_url": "https://www.allrecipes.com/recipe/222667/dal-makhani-indian-lentils/",
        "recipe_name": "dal makhani (indian lentils)",
        "recipe_short_description": "ever go to an indian restaurant and wonder how they make those lentils? i hated lentils before i discovered indian food then i scoured the internet to figure out how they achieved them and through mixing and matching recipes and methods on videos ive arrived at this recipe which i think is pretty close this version is very rich but you can leave out the cream to make it lighter kasuri methi (fenugreek leaves) is almost impossible to find in the us even in nyc but it gives this dish something very special",
        "image": [
            {
                "url": " \"https://images.media-allrecipes.com/userphotos/560x315/1257894.jpg\""
            }
        ],
        "recipe_calories": 390,
        "recipe_preptime": "4 h 15 m",
        "recipe_servings": "6",
        "recipe_ingredient": [
            {
                "ingredient_desc": "1 cup lentils",
                "amount": "1 ",
                "ingr": "cup lentils",
                "content": "lentils"
            },
            {
                "ingredient_desc": "1/4 cup dry kidney beans (optional)",
                "amount": "1/4 ",
                "ingr": "cup kidney beans",
                "content": "beans"
            },
            {
                "ingredient_desc": "water to cover",
                "amount": "",
                "ingr": "water",
                "content": "water cover"
            },
            {
                "ingredient_desc": "5 cups water",
                "amount": "5 ",
                "ingr": "cups water",
                "content": "water"
            },
            {
                "ingredient_desc": "salt to taste",
                "amount": "",
                "ingr": "salt taste",
                "content": "taste"
            },
            {
                "ingredient_desc": "2 tablespoons vegetable oil",
                "amount": "2 ",
                "ingr": "vegetable oil",
                "content": "oil"
            },
            {
                "ingredient_desc": "1 1/2 tablespoons ginger paste",
                "amount": "1/2 ",
                "ingr": "ginger paste",
                "content": "paste"
            },
            {
                "ingredient_desc": "1 1/2 tablespoons garlic paste",
                "amount": "1/2 ",
                "ingr": "paste",
                "content": "paste"
            },
            {
                "ingredient_desc": "1/2 teaspoon ground turmeric",
                "amount": "1/2 teaspoon",
                "ingr": "ground",
                "content": "turmeric"
            },
            {
                "ingredient_desc": "1 pinch cayenne pepper or more to taste",
                "amount": "1 ",
                "ingr": "pinch cayenne pepper",
                "content": "pepper taste"
            },
            {
                "ingredient_desc": "1 cup canned tomato puree or more to taste",
                "amount": "1 ",
                "ingr": "cup tomato puree",
                "content": "canned puree taste"
            },
            {
                "ingredient_desc": "1 tablespoon chili powder",
                "amount": "1 ",
                "ingr": "chili powder",
                "content": "powder"
            },
            {
                "ingredient_desc": "add all ingredients to list",
                "amount": "",
                "ingr": "",
                "content": ""
            }
        ],
        "recipe_description": "ever go to an indian restaurant and wonder how they make those lentils? i hated lentils before i discovered indian food then i scoured the internet to figure out how they achieved them and through mixing and matching recipes and methods on videos ive arrived at this recipe which i think is pretty close this version is very rich but you can leave out the cream to make it lighter kasuri methi (fenugreek leaves) is almost impossible to find in the us even in nyc but it gives this dish something very special",
        "recipe_procedure": [
            {
                "step": "0",
                "desc": "place lentils and kidney beans in a large bowl; cover with plenty of water soak for at least 2 hours or overnight drain"
            },
            {
                "step": "1",
                "desc": "cook lentils kidney beans 5 cups water and salt in a pot over medium heat until tender stirring occasionally about 1 hour remove from heat and set aside keep the lentils kidney beans and any excess cooking water in the pot"
            },
            {
                "step": "2",
                "desc": "heat vegetable oil in a saucepan over medium-high heat cook cumin seeds in the hot oil until they begin to pop 1 to 2 minutes add cardamom pods cinnamon stick bay leaves and cloves; cook until bay leaves turn brown about 1 minute reduce heat to medium-low; add ginger paste garlic paste turmeric and cayenne pepper stir to coat"
            },
            {
                "step": "3",
                "desc": "stir tomato puree into spice mixture; cook over medium heat until slightly reduced about 5 minutes add chili powder coriander and butter; cook and stir until butter is melted"
            },
            {
                "step": "4",
                "desc": "stir lentils kidney beans and any leftover cooking water into tomato mixture; bring to a boil reduce heat to low stir fenugreek into lentil mixture cover saucepan and simmer until heated through stirring occasionally about 45 minutes add cream and cook until heated through 2 to 4 minutes"
            }
        ],
        "recipe_nutrition": "per serving: 390 calories; 215 g fat; 371 g carbohydrates; 132 g protein; 48 mg cholesterol; 420 mg sodium full nutrition",
        "_id": 
    

    Пожалуйста, помогите мне в этом. Заранее спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...