# Help with searching in a nested property of a non-nested field

**URL:** <https://forum.opensearch.org/t/help-with-searching-in-a-nested-property-of-a-non-nested-field/16408>\
**Category:** OpenSearch\
**Created:** [October 24, 2023, 9:25am UTC](https://forum.opensearch.org/t/help-with-searching-in-a-nested-property-of-a-non-nested-field/16408 "2023-10-24T09:25:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joaocarlos](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@joaocarlos](https://forum.opensearch.org/u/joaocarlos)\
**Post date:** [October 24, 2023, 9:25am UTC](https://forum.opensearch.org/t/help-with-searching-in-a-nested-property-of-a-non-nested-field/16408/1 "2023-10-24T09:25:28Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):

Opensearch: 1.3.3

**Describe the issue** :

I’m trying to search on a nested property of another property that isn’t nested. My mappings looks like:

```auto
{
  "mappings": {
    "properties": {
      "my-non-nested-property": {
        "properties": {
          "my-nested-property": {
            "type": "nested",
            "properties": {
              "prop1": {
                "type": "text"
              },
              "prop2": {
                "type": "text"
              },
              "prop3": {
                "type": "keyword"
              },
              "prop4": {
                "properties": {
                  "type": {
                    "type": "text"
                  },
                  "value": {
                    "type": "text"
                  }
                }
              },
              "prop5": {
                "type": "text"
              },
              "prop6": {
                "type": "date"
              },
              "prop7": {
                "type": "date"
              }
            }
          },
          "index": {
            "type": "keyword"
          }
        }
      }
    }
  }
}

```

And this is the search I’m trying to use:

```auto
{
  "query": {
    "nested": {
      "path": "my-non-nested-property.my-nested-property",
      "query": {
        "bool": {
          "should": [
            {
              "term": {
                "my-non-nested-property.my-nested-property.prop1": "AVALUE"
              }
            }
          ]
        }
      }
    }
  }
}

```

I’ve populated the index with a single document that has a `my-non-nested-property.my-nested-property.prop1` set as “AVALUE”, but I cannot find the value using the filter I described. I’m new to opensearch, so I might be doing something wrong. I can confirm that if “my-nested-property” is a first-order property (on the same level as my-non-nested-property), I can search using nested queries, the problem seems when I have a nested property as a child of non-nested properties. I appreciate any advice about how to search on the described use-case.

Thank you,  
Best regards.

---

<div class="post-metadata">

**Author:** ![gaobinlong](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/gaobinlong/32/5242_2.png) [@gaobinlong](https://forum.opensearch.org/u/gaobinlong)\
**Post date:** [October 25, 2023, 2:29pm UTC](https://forum.opensearch.org/t/help-with-searching-in-a-nested-property-of-a-non-nested-field/16408/2 "2023-10-25T14:29:13Z")

</div>

The reason is that `prop1` is a text field which will be analyzed when indexing and searching, the original string in the text field will be tokenized, filtered, normalized and generate `terms`, in your case, `AVALUE ` will be lowercased and generate term `avalue`, so if you want to use term query(mostly perform on keyword type), you can search as this:

```auto
{
              "term": {
                "my-non-nested-property.my-nested-property.prop1": "avalue"
              }
            }

```

, or use match query on the text field:

```auto
{
              "match": {
                "my-non-nested-property.my-nested-property.prop1": "AVALUE"
              }
            }

```
