# Not able to search in attached content using Nest c# client

**URL:** <https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684>\
**Category:** Elasticsearch\
**Created:** [July 5, 2016, 3:05am UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684 "2016-07-05T03:05:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajoealex](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@ajoealex](https://discuss.elastic.co/u/ajoealex)\
**Post date:** [July 5, 2016, 3:05am UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684/1 "2016-07-05T03:05:16Z")

</div>

Hi, I have the an issue that I cannot search from the attached document using NEST client  
My mapping is

```
 {
   "mydocs": {
 "mappings": {
 "indexdocument": {
    "properties": {
       "docLocation": {
          "type": "string",
          "index": "not_analyzed",
          "store": true
       },
       "documentType": {
          "type": "string",
          "store": true
       },
       "file": {
          "type": "attachment",
          "fields": {
             "content": {
                "type": "string",
               "term_vector": "with_positions_offsets",
                "analyzer": "full"
             },
             "author": {
                "type": "string"
             },
             "title": {
                "type": "string",
                "term_vector": "with_positions_offsets",
                "analyzer": "full"
             },
             "name": {
                "type": "string"
             },
             "date": {
                "type": "date",
                "format": "strict_date_optional_time||epoch_millis"
             },
             "keywords": {
                "type": "string"
             },
             "content_type": {
                "type": "string"
             },
             "content_length": {
                "type": "integer"
             },
             "language": {
                "type": "string"
             }
          }
       },
       "filePermissionInfo": {
          "properties": {
             "accessControlType": {
                "type": "string",
                "store": true
             },
             "accountValue": {
                "type": "string",
                "store": true
             },
             "fileSystemRights": {
                "type": "string",
                "store": true
             },
             "isInherited": {
                "type": "string",
                "store": true
             }
          }
       },
       "id": {
          "type": "double",
          "store": true
       },
       "lastModifiedDate": {
          "type": "date",
          "store": true,
          "format": "strict_date_optional_time||epoch_millis"
       },
       "otherDetails": {
          "type": "string"
       },
       "title": {
          "type": "string",
          "store": true,
          "term_vector": "with_positions_offsets"
       }
    }
 }
}
 }
}

```

My Post query is working fine

```
POST /mydocs/_search
{
"query" : {
"bool" : {
    "must" : [
       
        { "match" : { "filePermissionInfo.accountValue" : "S-1-5-18"}} ,
       { "match":{"otherDetails":"xyz"}},
        { "match":{"file.content":"abc"}}              
       
    ]
}
}
}

```

But when I convert it to C#, Its not working. If I remove the ' m.Match(mt1 =\> mt1.Field(f1 =\> f1.File.Content).Query(queryTerm))' from the Nest query , it returns a resultset. So I think the problem is with the attachment field. It is base64 encoded

```
 var queryResult = client.Search<IndexDocument>(s => s
                        .Index("mydocs")
                        .Query(q => q
                        .Bool(b => b
                        .Must(m =>
                             m.Match(mt1 => mt1.Field(f1 => f1.DocumentType).Query(queryTerm)) &&
                             m.Match(mt2 => mt2.Field(f2 => f2.FilePermissionInfo.First().AccountValue).Query(accountName)) &&
                             m.Match(mt3 => mt3.Field(f3 => f3.OtherDetails).Query(other))
                         ))) );

```

Anyone please help.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 5, 2016, 5:19am UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684/2 "2016-07-05T05:19:03Z")

</div>

Moved to #development list.

---

<div class="post-metadata">

**Author:** ![KodrAus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodraus/32/22798_2.png) [@KodrAus](https://discuss.elastic.co/u/KodrAus)\
**Post date:** [July 5, 2016, 5:43am UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684/3 "2016-07-05T05:43:45Z")

</div>

What's the value of `queryResult.IsValid`? That will tell you whether the query was properly parsed and executed by Elasticsearch.

You can also poke around the properties on `queryResult` to find the json payload generated from your `client.Search` request.

---

<div class="post-metadata">

**Author:** ![ajoealex](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@ajoealex](https://discuss.elastic.co/u/ajoealex)\
**Post date:** [July 5, 2016, 6:03am UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684/4 "2016-07-05T06:03:46Z")

</div>

queryResult.IsValid is true

 ![](https://us1.discourse-cdn.com/elastic/original/2X/b/b229c72022b34cff28588b4c249d03d7ce1047e6.jpg)

---

<div class="post-metadata">

**Author:** ![KodrAus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodraus/32/22798_2.png) [@KodrAus](https://discuss.elastic.co/u/KodrAus)\
**Post date:** [July 5, 2016, 6:06am UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684/5 "2016-07-05T06:06:13Z")

</div>

What does the request JSON look like? I can't remember where it's stored off the top of my head, but if you expand that base class you've got highlighted in the screenshot it should be somewhere in there.

---

<div class="post-metadata">

**Author:** ![ajoealex](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@ajoealex](https://discuss.elastic.co/u/ajoealex)\
**Post date:** [July 5, 2016, 6:15am UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684/6 "2016-07-05T06:15:06Z")

</div>

I cannot find any JSON in the base class.I searched in most of the nodes under base.  
But in DebugInformation

```
 Successful low level call on POST: /mydocs/indexdocument/_search
# Audit trail of this API call:
 - HealthyResponse: Node: http://es_admin:Test1234@localhost:9200/ Took: 00:00:01.7965481
# Request:
<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
# Response:

```

\<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.\>

Will it make any sense.?

---

<div class="post-metadata">

**Author:** ![KodrAus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodraus/32/22798_2.png) [@KodrAus](https://discuss.elastic.co/u/KodrAus)\
**Post date:** [July 7, 2016, 10:06am UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684/7 "2016-07-07T10:06:42Z")

</div>

So it's saying that your request isn't malformed, so it's probably not generating the json you'd expect.

Try following that recommendation to disable direct streaming and see if it turns up then.

---

<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, 10:37pm UTC](https://discuss.elastic.co/t/not-able-to-search-in-attached-content-using-nest-c-client/54684/8 "2017-07-05T22:37:25Z")

</div>


