# ElasticSearch Low Level Client search using anonymous type

**URL:** <https://discuss.elastic.co/t/elasticsearch-low-level-client-search-using-anonymous-type/320668>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 7, 2022, 10:11am UTC](https://discuss.elastic.co/t/elasticsearch-low-level-client-search-using-anonymous-type/320668 "2022-12-07T10:11:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gjahagir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gjahagir/32/125175_2.png) [@gjahagir](https://discuss.elastic.co/u/gjahagir)\
**Post date:** [December 7, 2022, 10:11am UTC](https://discuss.elastic.co/t/elasticsearch-low-level-client-search-using-anonymous-type/320668/1 "2022-12-07T10:11:56Z")

</div>

Hi,

We are exploring Elastic search to see if it fits into our application requirements.

We would want to search using anonymous type, here is what i found in the documentation -

```auto
var searchResponse = lowlevelClient.Search<StringResponse>("people", PostData.Serializable(new
{
    from = 0,
    size = 10,
    query = new
    {
        wildcard= new
        {
            firstName = new
            {
                value = "Martijn"
            }
        }
    }
}));

var successful = searchResponse.Success;
var responseJson = searchResponse.Body;

```

I would want to search on firstName.keyword field but i couldn't specify a . (dot)

> firstName.keyword

on wildcard search field and it gives a compilation error.

i'm using NEST .NET library.

Any help on this please.

---

<div class="post-metadata">

**Author:** ![stevejgordon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevejgordon/32/80912_2.png) [@stevejgordon](https://discuss.elastic.co/u/stevejgordon)\
**Post date:** [December 13, 2022, 1:16pm UTC](https://discuss.elastic.co/t/elasticsearch-low-level-client-search-using-anonymous-type/320668/2 "2022-12-13T13:16:38Z")

</div>

Hi, @gjahagir.

This is possible with anonymous types but requires a workaround because the properties cannot contain period characters. You could achieve it with something like this:

```auto
var searchResponse = lowlevelClient.Search<StringResponse>("people", PostData.Serializable(new
{
    from = 0,
    size = 10,
    query = new
    {
        wildcard= new
        {
            firstName = new Dictionary<string, object>
            {
                ["firstname.keyword"] = "Martijn",
            }
        }
    }
}));

```

---

<div class="post-metadata">

**Author:** ![gjahagir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gjahagir/32/125175_2.png) [@gjahagir](https://discuss.elastic.co/u/gjahagir)\
**Post date:** [December 16, 2022, 10:13am UTC](https://discuss.elastic.co/t/elasticsearch-low-level-client-search-using-anonymous-type/320668/3 "2022-12-16T10:13:38Z")

</div>

Thanks for the help that worked

---

<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:** [January 13, 2023, 10:13am UTC](https://discuss.elastic.co/t/elasticsearch-low-level-client-search-using-anonymous-type/320668/4 "2023-01-13T10:13:47Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
