# Apply a wildcard query to a nested object

**URL:** <https://discuss.elastic.co/t/apply-a-wildcard-query-to-a-nested-object/43238>\
**Category:** Elasticsearch\
**Created:** [March 2, 2016, 11:52am UTC](https://discuss.elastic.co/t/apply-a-wildcard-query-to-a-nested-object/43238 "2016-03-02T11:52:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![verisimilitude](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/verisimilitude/32/8209_2.png) [@verisimilitude](https://discuss.elastic.co/u/verisimilitude)\
**Post date:** [March 2, 2016, 11:52am UTC](https://discuss.elastic.co/t/apply-a-wildcard-query-to-a-nested-object/43238/1 "2016-03-02T11:52:17Z")

</div>

I have the below structure (small part of a very large elastic-search document)

```
sample: {
   {
       "md5sum":"4002cbda13066720513d1c9d55dba809",
       "id":1,
       "sha256sum":"1c6e77ec49413bf7043af2058f147fb147c4ee741fb478872f072d063f2338c5",
       "sha1sum":"ba1e6e9a849fb4e13e92b33d023d40a0f105f908",
       "created_at":"2016-02-02T14:25:19+00:00",
       "updated_at":"2016-02-11T20:43:22+00:00",
       "file_size":188416,
       "type":{
          "name":"EXE"
       },
       "tags":[

       ],
       "sampleSources":[
          {
             "filename":"4002cbda13066720513d1c9d55dba809",
             "source":{
                "name":"default"
             }
          },
         {
             "filename":"4002cbda13066720332513d1c9d55dba809",
             "source":{
                "name":"default"
             }
          }
       ]
    }
}

```

The filter I would like to use is to find by the 'name' contained within sample.sampleSources.source using elastic search. I would like to use the wildcard query for the name. Below is the query I am trying.

```
GET /app/sample/_search
    {
       "query": {
          "nested": {
             "path": "sampleSources.source",
             "query": {
                 "wildcard": {
                    "sampleSources.source.name": "def*"
                 }
             }
          }
       }
    } 

```

Below is the mapping

```
{  
   "app":{  
      "mappings":{  
         "sample":{  
            "sampleSources":{  
               "type":"nested",
               "properties":{  
                  "filename":{  
                     "type":"string"
                  },
                  "source":{  
                     "type":"nested",
                     "properties":{  
                        "name":{  
                           "type":"string"
                        }
                     }
                  }
               }
            }
         }
      }
   }
}

```

The elastic search version which I have is 1.5.2, lucene version 4.10.4. I don't see a reason why this not not work, can someone please guide?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:12pm UTC](https://discuss.elastic.co/t/apply-a-wildcard-query-to-a-nested-object/43238/2 "2017-07-05T23:12:06Z")

</div>


