Remove _source when searching


(elyrank) #1

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" -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.
For more options, visit https://groups.google.com/groups/opt_out.


(David Pilato) #2

You should store the file.file field.
Have a look at this: https://gist.github.com/dadoonet/3907010

HTH

David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 17 sept. 2013 à 08:49, Elyran Kogan 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" -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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.


(elyrank) #3

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" -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 wrote:

You should store the file.file field.
Have a look at this: https://gist.github.com/dadoonet/3907010

HTH

David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 17 sept. 2013 à 08:49, Elyran Kogan 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" -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.
For more options, visit 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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4