# Document search using Rest High Level Client

**URL:** <https://discuss.elastic.co/t/document-search-using-rest-high-level-client/154565>\
**Category:** Elasticsearch\
**Created:** [October 30, 2018, 5:48am UTC](https://discuss.elastic.co/t/document-search-using-rest-high-level-client/154565 "2018-10-30T05:48:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanjaybg](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Sanjaybg](https://discuss.elastic.co/u/Sanjaybg)\
**Post date:** [October 30, 2018, 5:48am UTC](https://discuss.elastic.co/t/document-search-using-rest-high-level-client/154565/1 "2018-10-30T05:48:07Z")

</div>

I am trying to upload a document index it and search within the document but i am not able to. I am using Rest High Level Client. I have added ingest plugin. I think i'm not using the proper way to index the document. Can anyone help me to achieve this.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [October 30, 2018, 5:49am UTC](https://discuss.elastic.co/t/document-search-using-rest-high-level-client/154565/2 "2018-10-30T05:49:09Z")

</div>

> but i am not able to

You'll need to be more specific than that.

What exactly have you tried, and what is going wrong?

---

<div class="post-metadata">

**Author:** ![Sanjaybg](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Sanjaybg](https://discuss.elastic.co/u/Sanjaybg)\
**Post date:** [October 30, 2018, 6:05am UTC](https://discuss.elastic.co/t/document-search-using-rest-high-level-client/154565/3 "2018-10-30T06:05:52Z")

</div>

I'm uploading a file and with that i'm passing few fields. And i want index that.

String base64Content = Base64.encodeBase64String(file.get());  
XContentBuilder content = null;  
content = XContentFactory.jsonBuilder();  
content.startObject();  
content.field("Module", "Knowledge");  
content.field(base64Content);  
content.field(entityId);  
content.field("Id", tKnowledge.getId());  
content.field("Archive", tKnowledge.getArchive());  
content.endObject();

```
		public static void indexKnowledgeDocument(String index, String type, XContentBuilder content, String id) {
	RestHighLevelClient client = IndexUtils.getIndexClient();
	PutPipelineRequest pipelineRequest = new PutPipelineRequest(id,content);
	try {
		AcknowledgedResponse response = client.ingest().putPipeline(pipelineRequest, RequestOptions.DEFAULT);
	} catch (IOException e) {
		e.printStackTrace();
	}
	try {
		client.close();
	} catch (IOException e) {
		e.printStackTrace();
	}		
}

```

when im passing the content im passing with the other fields too. for indexing document only should i pass the file or with the other fields also can i pass?

If what im doing is not the proper way then what is the way to index a document and search from it.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [October 30, 2018, 8:33am UTC](https://discuss.elastic.co/t/document-search-using-rest-high-level-client/154565/4 "2018-10-30T08:33:51Z")

</div>

The PutPipelineRequest is used to [store a pipeline](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/put-pipeline-api.html) not a document.

You want to use the [Index API](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.4/java-rest-high-document-index.html).

---

<div class="post-metadata">

**Author:** ![Sanjaybg](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Sanjaybg](https://discuss.elastic.co/u/Sanjaybg)\
**Post date:** [October 30, 2018, 12:23pm UTC](https://discuss.elastic.co/t/document-search-using-rest-high-level-client/154565/5 "2018-10-30T12:23:44Z")

</div>

I have a module called knowledge. I'm creating an index request with all other properties, one particular property is an attachment, it can be word/pdf and i want to search inside that attachment document also. Before i was using mapper attachments plugin. I saw that its replaced with ingest plugin now, So i was trying like how i have showed above. So what i need to follow to search in attachments,  
[https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.4/java-rest-high-document-index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.4/java-rest-high-document-index.html)  
or  
[https://www.elastic.co/guide/en/elasticsearch/reference/6.4/ingest-apis.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/ingest-apis.html)

---

<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:** [November 27, 2018, 12:23pm UTC](https://discuss.elastic.co/t/document-search-using-rest-high-level-client/154565/6 "2018-11-27T12:23:53Z")

</div>

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