Search always return the original file

Hello,
I am able to search binary documents, but the search response always has the
original file content. How not to get the file content back in the search
response?

This is how I create the search and build the JSON string:

FieldQueryBuilder builder = new FieldQueryBuilder ("file", keywords);
SearchResponse searchResponse =
client.prepareSearch(this.indexName).setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(builder).execute().actionGet();

XContentBuilder b = XContentFactory.jsonBuilder();
b.startObject();
searchResponse.toXContent(b, ToXContent.EMPTY_PARAMS);
b.endObject();
return b.string();
thanks,
canal

This is my mapping file but the "file" is still returned as part of the search
result:

{
document : {
properties : {
"file" : { type : "attachment", store: "no" }
}
}
}

This is how I create the index:

String mapping =
IOUtils.toString(getClass().getResourceAsStream("/test-mapping.json"));
client.admin().indices().create(new
CreateIndexRequest(indexName).mapping(indexType, mapping)).actionGet();
client.admin().cluster().health(new
ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();
Did I miss out anything?

thanks,
canal


From: go canal gocanal@yahoo.com
To: users@elasticsearch.com
Sent: Sat, March 5, 2011 12:22:28 PM
Subject: search always return the original file

Hello,
I am able to search binary documents, but the search response always has the
original file content. How not to get the file content back in the search
response?

This is how I create the search and build the JSON string:

FieldQueryBuilder builder = new FieldQueryBuilder ("file", keywords);
SearchResponse searchResponse =
client.prepareSearch(this.indexName).setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(builder).execute().actionGet();

XContentBuilder b = XContentFactory.jsonBuilder();
b.startObject();
searchResponse.toXContent(b, ToXContent.EMPTY_PARAMS);
b.endObject();
return b.string();
thanks,
canal

Hi Canal,

you are getting back the document content in the response because it is part
of the _source field which is returned for each hit by default. Try to check
field query
Elasticsearch Platform — Find real-time answers at scale | Elastic to
selectively return only specific field values.

Regards,
Lukas

On Sat, Mar 5, 2011 at 9:42 AM, go canal gocanal@yahoo.com wrote:

This is my mapping file but the "file" is still returned as part of the
search result:

{
document : {
properties : {
"file" : { type : "attachment", store: "no" }
}
}
}

This is how I create the index:

String mapping =
IOUtils.toString(getClass().getResourceAsStream("/test-mapping.json"));
client.admin().indices().create(new
CreateIndexRequest(indexName).mapping(indexType, mapping)).actionGet();
client.admin().cluster().health(new
ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();

Did I miss out anything?

thanks,
canal


From: go canal gocanal@yahoo.com
To: users@elasticsearch.com
Sent: Sat, March 5, 2011 12:22:28 PM
Subject: search always return the original file

Hello,
I am able to search binary documents, but the search response always has
the original file content. How not to get the file content back in the
search response?

This is how I create the search and build the JSON string:

FieldQueryBuilder builder = new FieldQueryBuilder ("file", keywords);
SearchResponse searchResponse =
client.prepareSearch(this.indexName).setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(builder).execute().actionGet();

XContentBuilder b = XContentFactory.jsonBuilder();
b.startObject();
searchResponse.toXContent(b, ToXContent.EMPTY_PARAMS);
b.endObject();
return b.string();

thanks,
canal

Thank you very much Lukas, it works !
thanks,
canal


From: Lukáš Vlček lukas.vlcek@gmail.com
To: users@elasticsearch.com
Sent: Sun, March 6, 2011 4:21:43 AM
Subject: Re: search always return the original file

Hi Canal,

you are getting back the document content in the response because it is part of
the _source field which is returned for each hit by default. Try to check field
query Elasticsearch Platform — Find real-time answers at scale | Elastic to
selectively return only specific field values.

Regards,
Lukas

On Sat, Mar 5, 2011 at 9:42 AM, go canal gocanal@yahoo.com wrote:

This is my mapping file but the "file" is still returned as part of the search
result:

{
document : {
properties : {
"file" : { type : "attachment", store: "no" }
}
}
}

This is how I create the index:

String mapping =
IOUtils.toString(getClass().getResourceAsStream("/test-mapping.json"));
client.admin().indices().create(new
CreateIndexRequest(indexName).mapping(indexType, mapping)).actionGet();
client.admin().cluster().health(new
ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();

Did I miss out anything?

thanks,
canal


From: go canal gocanal@yahoo.com

To: users@elasticsearch.com
Sent: Sat, March 5, 2011 12:22:28 PM
Subject: search always return the original file

Hello,
I am able to search binary documents, but the search response always has the
original file content. How not to get the file content back in the search
response?

This is how I create the search and build the JSON string:

FieldQueryBuilder builder = new FieldQueryBuilder ("file", keywords);
SearchResponse searchResponse =
client.prepareSearch(this.indexName).setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(builder).execute().actionGet();

XContentBuilder b = XContentFactory.jsonBuilder();
b.startObject();
searchResponse.toXContent(b, ToXContent.EMPTY_PARAMS);
b.endObject();
return b.string();

thanks,
canal