Document search using Rest High Level Client

(Sanjay Kumar BG) #1

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.

(Tim Vernum) #2

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?

(Sanjay Kumar BG) #3

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.field("Module", "Knowledge");
content.field("Id", tKnowledge.getId());
content.field("Archive", tKnowledge.getArchive());

		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) {
	try {
	} catch (IOException e) {

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.

(Tim Vernum) #4

The PutPipelineRequest is used to store a pipeline not a document.

You want to use the Index API.

(Sanjay Kumar BG) #5

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,

(system) #6

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