# Not able to query MongoDB.Bson.ObjectId using ElasticSearch Nest Client

**URL:** <https://discuss.elastic.co/t/not-able-to-query-mongodb-bson-objectid-using-elasticsearch-nest-client/272375>\
**Category:** Elasticsearch\
**Created:** [May 7, 2021, 7:08am UTC](https://discuss.elastic.co/t/not-able-to-query-mongodb-bson-objectid-using-elasticsearch-nest-client/272375 "2021-05-07T07:08:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeeshan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zeeshan/32/88375_2.png) [@zeeshan](https://discuss.elastic.co/u/zeeshan)\
**Post date:** [May 7, 2021, 7:08am UTC](https://discuss.elastic.co/t/not-able-to-query-mongodb-bson-objectid-using-elasticsearch-nest-client/272375/1 "2021-05-07T07:08:58Z")

</div>

I have an field of type ObjectId (MongoDB.Bson) in my model, and when I index it elastic search server, it looks like following structure in Elastic Search:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/f/ffa3461b3230c3a718f173b988c46cec53f72fb9.png)  
My question is, how can query (using NEST client) to match this field? For example, if it was a string field, I would do something like:

```auto
     _elasticClient.Search<LineItem>(x => x
                .Index("lineitems")
                .Query(q => q
                       .Term(p => p.ClaimId, "xyzClaimId")
                    )
                );               

```

But ClaimId field is actually ObjectId type. How can i modify my query to get matched result?

---

<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:** [June 4, 2021, 7:09am UTC](https://discuss.elastic.co/t/not-able-to-query-mongodb-bson-objectid-using-elasticsearch-nest-client/272375/2 "2021-06-04T07:09:26Z")

</div>

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