About Nested Data Search

Hello, when I perform a query search in the Weaviate console as shown below, I receive the following data as a result. I want to create a GraphQL search using the ‘name’ and ‘quantity’ from the ‘ingredients’ key, and also use the ‘color’ value from the ‘properties’ key. How can I achieve this?

{
  Get {
    Adata (limit:2) {
      code
      description
      name
      ingredients {
        code
        name
        quantity
        unit
      }
      properties {
        color
        region
        viscosity
      }
    }
  }
}

Result:

{
  "data": {
    "Get": {
      "Adata": [
        {
          "code": "prd002",
          "description": "Savory Caesar Salad",
          "ingredients": [
            {
              "code": "xxx",
              "name": "Romaine lettuce",
              "quantity": "100",
              "unit": "gr"
            },
            {
              "code": "xxx",
              "name": "Grilled chicken",
              "quantity": "100",
              "unit": "gr"
            },
            {
              "code": "xxx",
              "name": "Parmesan cheese",
              "quantity": "50",
              "unit": "gr"
            },
            {
              "code": "xxx",
              "name": "Croutons",
              "quantity": "30",
              "unit": "gr"
            },
            {
              "code": "xxx",
              "name": "Caesar dressing",
              "quantity": "20",
              "unit": "gr"
            }
          ],
          "name": "Savory Caesar Salad",
          "properties": [
            {
              "color": "#a02",
              "region": "#c02",
              "viscosity": "#b02"
            }
          ]
        },
        {
          "code": "prd001",
          "description": "Sweet Strawberry Spinach Salad",
          "ingredients": [
            {
              "code": "xxx",
              "name": "Baby spinach",
              "quantity": "100",
              "unit": "gr"
            },
            {
              "code": "xxx",
              "name": "Strawberries",
              "quantity": "100",
              "unit": "gr"
            },
            {
              "code": "xxx",
              "name": "Goat cheese",
              "quantity": "50",
              "unit": "gr"
            },
            {
              "code": "xxx",
              "name": "Candied pecans",
              "quantity": "30",
              "unit": "gr"
            },
            {
              "code": "xxx",
              "name": "Balsamic glaze",
              "quantity": "20",
              "unit": "gr"
            }
          ],
          "name": "Sweet Strawberry Spinach Salad",
          "properties": [
            {
              "color": "#a01",
              "region": "#c01",
              "viscosity": "#b01"
            }
          ]
        }
      ]
    }
  }
}

Server Setup Information

  • Weaviate Server Version:
    semitechnologies/weaviate:1.23.10

My Schema

{
  "classes": [
    {
      "class": "Adata",
      "description": "Information from data",
      "vectorizer": "text2vec-openai",
      "moduleConfig": {
        "text2vec-openai": {
          "model": "ada",
          "type": "text"
        }
      },
      "properties": [
        {
          "dataType": [
            "text"
          ],
          "description": "Product name",
          "moduleConfig": {
            "text2vec-openai": {
              "skip": "false",
              "vectorizePropertyName": "false"
            }
          },
          "name": "name"
        },
        {
            "dataType": ["object"],
            "name": "ingredients",
            "nestedProperties": [
                {"dataType": ["text"], "name": "code"},
                {"dataType": ["text"], "name": "name"},
                {"dataType": ["number"], "name": "quantity"},
                {"dataType": ["text"], "name": "unit"}
            ],
            "description": "The ingredients",
            "moduleConfig": {
                "text2vec-openai": {
                  "skip": "false",
                  "vectorizePropertyName": "false"
                }
            }
        },
        {
            "dataType": ["object"],
            "name": "properties",
            "nestedProperties": [
                {"dataType": ["text"], "name": "color"},
                {"dataType": ["text"], "name": "viscosity"},
                {"dataType": ["text"], "name": "region"}
            ],
            "description": "The properties",
            "moduleConfig": {
                "text2vec-openai": {
                  "skip": "false",
                  "vectorizePropertyName": "false"
                }
            }
        },
        {
          "dataType": [
            "text"
          ],
          "description": "The code",
          "moduleConfig": {
            "text2vec-openai": {
              "skip": "false",
              "vectorizePropertyName": "false"
            }
          },
          "name": "code"
        }
      ]
    }
  ]
}

Hi @exsbandit ! Welcome to our community :hugs:

For now, It’s not possible to filter and get it’s data vectorized for nested objects.

Here we have a feature request:

Please, leave your thumbs up so we can make it a priority in our roadmap:

Let me know if that helps.

Thanks!

Thanks @DudaNogueira for your answer,

Can you suggest how I can insert and search the following JSON data? For example, I need to make checks with a query where ‘ingredients’ → ‘name’ is ‘cheese’ and ‘properties’ → ‘color’ is ‘red’.

[
    {
       "code":"prd001",
       "properties":[
          {
             "color":"#a01",
             "viscosity":"#b01",
             "region":"#c01"
          }
       ],
       "name":"Sweet Strawberry Spinach Salad",
       "ingredients":[
          {
             "code":"xxx",
             "name":"Baby spinach",
             "quantity":"100",
             "unit":"gr"
          },
          {
             "code":"xxx",
             "name":"Strawberries",
             "quantity":"100",
             "unit":"gr"
          },
          {
             "code":"xxx",
             "name":"Goat cheese",
             "quantity":"50",
             "unit":"gr"
          },
          {
             "code":"xxx",
             "name":"Candied pecans",
             "quantity":"30",
             "unit":"gr"
          },
          {
             "code":"xxx",
             "name":"Balsamic glaze",
             "quantity":"20",
             "unit":"gr"
          }
       ]
    },
    {
       "code":"prd002",
       "properties":[
          {
             "color":"#a02",
             "viscosity":"#b02",
             "region":"#c02"
          }
       ],
       "name":"Savory Caesar Salad",
       "ingredients":[
          {
             "code":"xxx",
             "name":"Romaine lettuce",
             "quantity":"100",
             "unit":"gr"
          },
          {
             "code":"xxx",
             "name":"Grilled chicken",
             "quantity":"100",
             "unit":"gr"
          },
          {
             "code":"xxx",
             "name":"Parmesan cheese",
             "quantity":"50",
             "unit":"gr"
          },
          {
             "code":"xxx",
             "name":"Croutons",
             "quantity":"30",
             "unit":"gr"
          },
          {
             "code":"xxx",
             "name":"Caesar dressing",
             "quantity":"20",
             "unit":"gr"
          }
       ]
    },
.
.
.

You will have to ingest those properties as text.

So you will endup with a “flat” object.

Let me know if that helps :slight_smile: