# Remove \_source when searching

**URL:** <https://discuss.elastic.co/t/remove--source-when-searching/13638>\
**Category:** Elasticsearch\
**Created:** [September 17, 2013, 6:49am UTC](https://discuss.elastic.co/t/remove--source-when-searching/13638 "2013-09-17T06:49:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elyrank](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elyrank/32/2072_2.png) [@elyrank](https://discuss.elastic.co/u/elyrank)\
**Post date:** [September 17, 2013, 6:49am UTC](https://discuss.elastic.co/t/remove--source-when-searching/13638/1 "2013-09-17T06:49:38Z")

</div>

Hi,

I am new to elasticsearch , and in the middle of setting up my first  
elasticsearch server.

I am using the attachment plugin, and I'm indexing files - mainly html,

when I"m using the java API - I'm able to query and get the highlights, and  
the relevant fields of the file -  
i.e. file.title, file.content\_type

but when I'm using curl - I get the \_source which can be big because the  
file contains all the base64 encoded file which I don't need,  
and I don't get the file.\* fields.

this is my java search:

SearchRequestBuilder searchBuilder = client.prepareSearch().setQuery(query)  
.addField(TITLE)  
.addField(PATH)  
.addField(CONTENT\_TYPE)  
.addHighlightedField(FILE);  
return searchBuilder.execute().actionGet();

this is my curl search:

curl -XPOST "[http://localhost:9200/\_search](http://localhost:9200/_search)" -d'  
{  
"query": {  
"query\_string": {  
"fields" : ["title", "content\_type", "path"],  
"query": "my search"  
}  
},  
"highlight" : {  
"fields" : {  
"file" : {"fragment\_size" : 50, "number\_of\_fragments" : 3}  
}  
}

}'

what am I doing wrong?

thanks,  
Elyran

--  
This message may contain confidential and/or privileged information.  
If you are not the addressee or authorized to receive this on behalf of the  
addressee you must not use, copy, disclose or take action based on this  
message or any information herein.  
If you have received this message in error, please advise the sender  
immediately by reply email and delete this message. Thank you.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [September 17, 2013, 6:57am UTC](https://discuss.elastic.co/t/remove--source-when-searching/13638/2 "2013-09-17T06:57:00Z")

</div>

You should store the file.file field.  
Have a look at this: [Test of attachments plugin · GitHub](https://gist.github.com/dadoonet/3907010)

## HTH

David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 17 sept. 2013 à 08:49, Elyran Kogan [elyran@liveperson.com](mailto:elyran@liveperson.com) a écrit :

> Hi,
> 
> I am new to elasticsearch , and in the middle of setting up my first elasticsearch server.
> 
> I am using the attachment plugin, and I'm indexing files - mainly html,
> 
> when I"m using the java API - I'm able to query and get the highlights, and the relevant fields of the file -  
> i.e. file.title, file.content\_type
> 
> but when I'm using curl - I get the \_source which can be big because the file contains all the base64 encoded file which I don't need,  
> and I don't get the file.\* fields.
> 
> this is my java search:
> 
> SearchRequestBuilder searchBuilder = client.prepareSearch().setQuery(query)  
> .addField(TITLE)  
> .addField(PATH)  
> .addField(CONTENT\_TYPE)  
> .addHighlightedField(FILE);  
> return searchBuilder.execute().actionGet();
> 
> this is my curl search:
> 
> curl -XPOST "[http://localhost:9200/\_search](http://localhost:9200/_search)" -d'  
> {  
> "query": {  
> "query\_string": {  
> "fields" : ["title", "content\_type", "path"],  
> "query": "my search"  
> }  
> },  
> "highlight" : {  
> "fields" : {  
> "file" : {"fragment\_size" : 50, "number\_of\_fragments" : 3}  
> }  
> }
> 
> }'
> 
> what am I doing wrong?
> 
> thanks,  
> Elyran
> 
> This message may contain confidential and/or privileged information.  
> If you are not the addressee or authorized to receive this on behalf of the addressee you must not use, copy, disclose or take action based on this message or any information herein.  
> If you have received this message in error, please advise the sender immediately by reply email and delete this message. Thank you.
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![elyrank](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elyrank/32/2072_2.png) [@elyrank](https://discuss.elastic.co/u/elyrank)\
**Post date:** [September 17, 2013, 9:21am UTC](https://discuss.elastic.co/t/remove--source-when-searching/13638/3 "2013-09-17T09:21:16Z")

</div>

I looked at the link you send and found out that I put the fields in the  
wrong place , so when I did this:

curl -XPOST "[http://localhost:9200/\_search?pretty=true](http://localhost:9200/_search?pretty=true)" -d'  
{  
"fields" : ["title", "content\_type", "path"],  
"query": {  
"query\_string": {  
"query": "esapi"  
}  
},  
"highlight" : {  
"fields" : {  
"file" : {"fragment\_size" : 50, "number\_of\_fragments" : 3}  
}  
}

}'

I got only the fields I needed

thanks

On Tue, Sep 17, 2013 at 8:57 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> You should store the file.file field.  
> Have a look at this: [Test of attachments plugin · GitHub](https://gist.github.com/dadoonet/3907010)
> 
> ## HTH
> 
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 17 sept. 2013 à 08:49, Elyran Kogan [elyran@liveperson.com](mailto:elyran@liveperson.com) a écrit :
> 
> Hi,
> 
> I am new to elasticsearch , and in the middle of setting up my first  
> elasticsearch server.
> 
> I am using the attachment plugin, and I'm indexing files - mainly html,
> 
> when I"m using the java API - I'm able to query and get the highlights,  
> and the relevant fields of the file -  
> i.e. file.title, file.content\_type
> 
> but when I'm using curl - I get the \_source which can be big because the  
> file contains all the base64 encoded file which I don't need,  
> and I don't get the file.\* fields.
> 
> this is my java search:
> 
> SearchRequestBuilder searchBuilder = client.prepareSearch().setQuery(query)  
> .addField(TITLE)  
> .addField(PATH)  
> .addField(CONTENT\_TYPE)  
> .addHighlightedField(FILE);  
> return searchBuilder.execute().actionGet();
> 
> this is my curl search:
> 
> curl -XPOST "[http://localhost:9200/\_search](http://localhost:9200/_search)" -d'  
> {  
> "query": {  
> "query\_string": {  
> "fields" : ["title", "content\_type", "path"],  
> "query": "my search"  
> }  
> },  
> "highlight" : {  
> "fields" : {  
> "file" : {"fragment\_size" : 50, "number\_of\_fragments" : 3}  
> }  
> }
> 
> }'
> 
> what am I doing wrong?
> 
> thanks,  
> Elyran
> 
> This message may contain confidential and/or privileged information.  
> If you are not the addressee or authorized to receive this on behalf of  
> the addressee you must not use, copy, disclose or take action based on this  
> message or any information herein.  
> If you have received this message in error, please advise the sender  
> immediately by reply email and delete this message. Thank you.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Thanks,  
Elyran KoganLivePerson, Inc.Software DeveloperT +972 74 700 4387F +972 74  
700 492013 Zarchin StreetPO Box 2067, Industrial AreaRa'anana 43100,  
IsraelMeaningful  
connections through intelligent engagement.™

--  
This message may contain confidential and/or privileged information.  
If you are not the addressee or authorized to receive this on behalf of the  
addressee you must not use, copy, disclose or take action based on this  
message or any information herein.  
If you have received this message in error, please advise the sender  
immediately by reply email and delete this message. Thank you.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:16am UTC](https://discuss.elastic.co/t/remove--source-when-searching/13638/4 "2017-07-06T02:16:04Z")

</div>


