Elasticsearch-hadoop - getting specified fields from elasticsearch as an input to a mapreduce job

I'm trying to write a mapreduce job where I can query elasticsearch so it
can return to me specific fields. Is there any way to do that?

My mapping contains about 30 fields and I will need just 4 of them
("_id","title","description","category")

The way I was doing it is to process each answer to get those fields, but
I'm looking for a cleaner way to do that.

Any help or suggestion is appreciated.

Thanks!

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simply specify the fields that you are interested in, in the query and you are good to go.

[1] Elasticsearch Platform — Find real-time answers at scale | Elastic

On 12/2/14 12:52 PM, Elias Abou Haydar wrote:

I'm trying to write a mapreduce job where I can query elasticsearch so it can return to me specific fields. Is there any
way to do that?

My mapping contains about 30 fields and I will need just 4 of them ("_id","title","description","category")

The way I was doing it is to process each answer to get those fields, but I'm looking for a cleaner way to do that.

Any help or suggestion is appreciated.

Thanks!

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout.

--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/547DA43B.4020305%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

That works fine for me thank you! But I'd also wanted to be able to build
and object from the MapWritable values in the mapper.

Consider values as MapWritable object.
When I try to get a specified value from values.get("title") per example
the returning value is null but the field exists in the values.keySet()

Considering the following code :

System.out.println(values.keySet());
System.out.println(values.toString());
System.out.println("title : " + values.get("title"));
System.out.println("category : " + values.get("category"));

This is a snippet from the debug output :

[title, categoryId]
{title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]}
title : null
category : null

Thanks again!

Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit :

Simply specify the fields that you are interested in, in the query and you
are good to go.

[1]
Elasticsearch Platform — Find real-time answers at scale | Elastic

On 12/2/14 12:52 PM, Elias Abou Haydar wrote:

I'm trying to write a mapreduce job where I can query elasticsearch so
it can return to me specific fields. Is there any
way to do that?

My mapping contains about 30 fields and I will need just 4 of them
("_id","title","description","category")

The way I was doing it is to process each answer to get those fields,
but I'm looking for a cleaner way to do that.

Any help or suggestion is appreciated.

Thanks!

--
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
elasticsearc...@googlegroups.com <javascript:> <mailto:
elasticsearch+unsubscribe@googlegroups.com <javascript:>>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<
https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>.

For more options, visit https://groups.google.com/d/optout.

--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

That's because your MapWritables doesn't use Strings as keys but rather org.apache.hadoop.io.Text
In other words, you can see the data is in the map however you cannot retrieve it since you are using the wrong key (try
inspecting the map object types).

Try values.get(new Text("title"))

On 12/3/14 3:04 PM, Elias Abou Haydar wrote:

That works fine for me thank you! But I'd also wanted to be able to build and object from the MapWritable values in the
mapper.

Consider values as MapWritable object.
When I try to get a specified value from values.get("title") per example the returning value is null but the field
exists in the values.keySet()

Considering the following code :

System.out.println(values.keySet());
System.out.println(values.toString());
System.out.println("title : " + values.get("title"));
System.out.println("category : " + values.get("category"));

This is a snippet from the debug output :

[title, categoryId]
{title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]}
title : null
category : null

Thanks again!

Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit :

Simply specify the fields that you are interested in, in the query and you are good to go.

[1] http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html>

On 12/2/14 12:52 PM, Elias Abou Haydar wrote:
> I'm trying to write a mapreduce job where I can query elasticsearch so it can return to me specific fields. Is there any
> way to do that?
>
> My mapping contains about 30 fields and I will need just 4 of them ("_id","title","description","category")
>
> The way I was doing it is to process each answer to get those fields, but I'm looking for a cleaner way to do that.
>
> Any help or suggestion is appreciated.
>
> Thanks!
>
> --
> 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
>elasticsearc...@googlegroups.com <javascript:> <mailto:elasticsearch+unsubscribe@googlegroups.com <javascript:>>.
> To view this discussion on the web visit
>https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>
> <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>.

> For more options, visithttps://groups.google.com/d/optout <https://groups.google.com/d/optout>.

--
Costin

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout.
--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/547F0BA3.4050603%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

I've tried that. It returns a
org.elasticsearch.hadoop.mr.WritableArrayWritable object. How can I get my
field content out of that?

Le mercredi 3 décembre 2014 14:10:24 UTC+1, Costin Leau a écrit :

That's because your MapWritables doesn't use Strings as keys but rather
org.apache.hadoop.io.Text
In other words, you can see the data is in the map however you cannot
retrieve it since you are using the wrong key (try
inspecting the map object types).

Try values.get(new Text("title"))

On 12/3/14 3:04 PM, Elias Abou Haydar wrote:

That works fine for me thank you! But I'd also wanted to be able to
build and object from the MapWritable values in the
mapper.

Consider values as MapWritable object.
When I try to get a specified value from values.get("title") per example
the returning value is null but the field
exists in the values.keySet()

Considering the following code :

System.out.println(values.keySet());
System.out.println(values.toString());
System.out.println("title : " + values.get("title"));
System.out.println("category : " + values.get("category"));

This is a snippet from the debug output :

[title, categoryId]
{title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]}
title : null
category : null

Thanks again!

Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit :

Simply specify the fields that you are interested in, in the query 

and you are good to go.

[1] 

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>

On 12/2/14 12:52 PM, Elias Abou Haydar wrote: 
> I'm trying to write a mapreduce job where I can query 

elasticsearch so it can return to me specific fields. Is there any

> way to do that? 
> 
> My mapping contains about 30 fields and I will need just 4 of them 

("_id","title","description","category")

> 
> The way I was doing it is to process each answer to get those 

fields, but I'm looking for a cleaner way to do that.

> 
> Any help or suggestion is appreciated. 
> 
> Thanks! 
> 
> -- 
> 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

>elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:> <javascript:>>.

> To view this discussion on the web visit 
>

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>

> <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>.

> For more options, visithttps://groups.google.com/d/optout <

https://groups.google.com/d/optout>.

-- 
Costin 

--
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
elasticsearc...@googlegroups.com <javascript:> <mailto:
elasticsearch+unsubscribe@googlegroups.com <javascript:>>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com

<
https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>.

For more options, visit https://groups.google.com/d/optout.
--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You're getting back an array ([Samsung EF-C....]) - a Writable wrapper around org.hadoop.io.ArrayWritable (to actually
allow it to be serialized).
So call toStrings() or get() to get its content.

On 12/3/14 3:30 PM, Elias Abou Haydar wrote:

I've tried that. It returns a org.elasticsearch.hadoop.mr.WritableArrayWritable object. How can I get my field content
out of that?

Le mercredi 3 décembre 2014 14:10:24 UTC+1, Costin Leau a écrit :

That's because your MapWritables doesn't use Strings as keys but rather org.apache.hadoop.io.Text
In other words, you can see the data is in the map however you cannot retrieve it since you are using the wrong key
(try
inspecting the map object types).

Try values.get(new Text("title"))


On 12/3/14 3:04 PM, Elias Abou Haydar wrote:
> That works fine for me thank you! But I'd also wanted to be able to build and object from the MapWritable values in the
> mapper.
>
> Consider values as MapWritable object.
> When I try to get a specified value from values.get("title") per example the returning value is null but the field
> exists in the values.keySet()
>
> Considering the following code :
>
> System.out.println(values.keySet());
> System.out.println(values.toString());
> System.out.println("title : " + values.get("title"));
> System.out.println("category : " + values.get("category"));
>
> This is a snippet from the debug output :
>
> [title, categoryId]
> {title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]}
> title : null
> category : null
>
> Thanks again!
>
> Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit :
>
>     Simply specify the fields that you are interested in, in the query and you are good to go.
>
>     [1]http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html>
>     <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html>>
>
>     On 12/2/14 12:52 PM, Elias Abou Haydar wrote:
>     > I'm trying to write a mapreduce job where I can query elasticsearch so it can return to me specific fields. Is there any
>     > way to do that?
>     >
>     > My mapping contains about 30 fields and I will need just 4 of them ("_id","title","description","category")
>     >
>     > The way I was doing it is to process each answer to get those fields, but I'm looking for a cleaner way to do that.
>     >
>     > Any help or suggestion is appreciated.
>     >
>     > Thanks!
>     >
>     > --
>     > 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
>     >elasticsearc...@googlegroups.com <javascript:> <mailto:elasticsearch+unsubscribe@googlegroups.com <javascript:>
<javascript:>>.
>     > To view this discussion on the web visit
>     >https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>
>     <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>>
>     > <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>>.

>
>     > For more options, visithttps://groups.google.com/d/optout <http://groups.google.com/d/optout> <https://groups.google.com/d/optout
<https://groups.google.com/d/optout>>.
>
>     --
>     Costin
>
> --
> 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
>elasticsearc...@googlegroups.com <javascript:> <mailto:elasticsearch+unsubscribe@googlegroups.com <javascript:>>.
> To view this discussion on the web visit
>https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com>
> <https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>>.

> For more options, visithttps://groups.google.com/d/optout <https://groups.google.com/d/optout>.
--
Costin

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout.

--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/547F2A6A.4040807%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

I've already tried that. It doesn't work... :confused:

Le mercredi 3 décembre 2014 16:21:40 UTC+1, Costin Leau a écrit :

You're getting back an array ([Samsung EF-C....]) - a Writable wrapper
around org.hadoop.io.ArrayWritable (to actually
allow it to be serialized).
So call toStrings() or get() to get its content.

On 12/3/14 3:30 PM, Elias Abou Haydar wrote:

I've tried that. It returns a
org.elasticsearch.hadoop.mr.WritableArrayWritable object. How can I get my
field content
out of that?

Le mercredi 3 décembre 2014 14:10:24 UTC+1, Costin Leau a écrit :

That's because your MapWritables doesn't use Strings as keys but 

rather org.apache.hadoop.io.Text

In other words, you can see the data is in the map however you 

cannot retrieve it since you are using the wrong key

(try 
inspecting the map object types). 

Try values.get(new Text("title")) 


On 12/3/14 3:04 PM, Elias Abou Haydar wrote: 
> That works fine for me thank you! But I'd also wanted to be able 

to build and object from the MapWritable values in the

> mapper. 
> 
> Consider values as MapWritable object. 
> When I try to get a specified value from values.get("title") per 

example the returning value is null but the field

> exists in the values.keySet() 
> 
> Considering the following code : 
> 
> System.out.println(values.keySet()); 
> System.out.println(values.toString()); 
> System.out.println("title : " + values.get("title")); 
> System.out.println("category : " + values.get("category")); 
> 
> This is a snippet from the debug output : 
> 
> [title, categoryId] 
> {title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]} 
> title : null 
> category : null 
> 
> Thanks again! 
> 
> Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit : 
> 
>     Simply specify the fields that you are interested in, in the 

query and you are good to go.

> 
>     [1]

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>

>     <

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>>

> 
>     On 12/2/14 12:52 PM, Elias Abou Haydar wrote: 
>     > I'm trying to write a mapreduce job where I can query 

elasticsearch so it can return to me specific fields. Is there any

>     > way to do that? 
>     > 
>     > My mapping contains about 30 fields and I will need just 4 

of them ("_id","title","description","category")

>     > 
>     > The way I was doing it is to process each answer to get 

those fields, but I'm looking for a cleaner way to do that.

>     > 
>     > Any help or suggestion is appreciated. 
>     > 
>     > Thanks! 
>     > 
>     > -- 
>     > 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

>     >elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:> <javascript:>

<javascript:>>. 
>     > To view this discussion on the web visit 
>     >

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>>

>     > <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>>.

> 
>     > For more options, visithttps://groups.google.com/d/optout <

http://groups.google.com/d/optout> <https://groups.google.com/d/optout

<https://groups.google.com/d/optout>>. 
> 
>     -- 
>     Costin 
> 
> -- 
> 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

>elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:> <javascript:>>.

> To view this discussion on the web visit 
>

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com>

> <

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>>.

> For more options, visithttps://groups.google.com/d/optout <

https://groups.google.com/d/optout>.

-- 
Costin 

--
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
elasticsearc...@googlegroups.com <javascript:> <mailto:
elasticsearch+unsubscribe@googlegroups.com <javascript:>>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com

<
https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com?utm_medium=email&utm_source=footer>.

For more options, visit https://groups.google.com/d/optout.

--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e5aab47b-e04e-415b-9e61-c8f077ad1513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I've tried to call toStrings()
I got this :
title : [Ljava.lang.String;@35112ff7

with the get(), i'm getting this:
title : [Lorg.apache.hadoop.io.Writable;@666f5678

Le mercredi 3 décembre 2014 16:21:40 UTC+1, Costin Leau a écrit :

You're getting back an array ([Samsung EF-C....]) - a Writable wrapper
around org.hadoop.io.ArrayWritable (to actually
allow it to be serialized).
So call toStrings() or get() to get its content.

On 12/3/14 3:30 PM, Elias Abou Haydar wrote:

I've tried that. It returns a
org.elasticsearch.hadoop.mr.WritableArrayWritable object. How can I get my
field content
out of that?

Le mercredi 3 décembre 2014 14:10:24 UTC+1, Costin Leau a écrit :

That's because your MapWritables doesn't use Strings as keys but 

rather org.apache.hadoop.io.Text

In other words, you can see the data is in the map however you 

cannot retrieve it since you are using the wrong key

(try 
inspecting the map object types). 

Try values.get(new Text("title")) 


On 12/3/14 3:04 PM, Elias Abou Haydar wrote: 
> That works fine for me thank you! But I'd also wanted to be able 

to build and object from the MapWritable values in the

> mapper. 
> 
> Consider values as MapWritable object. 
> When I try to get a specified value from values.get("title") per 

example the returning value is null but the field

> exists in the values.keySet() 
> 
> Considering the following code : 
> 
> System.out.println(values.keySet()); 
> System.out.println(values.toString()); 
> System.out.println("title : " + values.get("title")); 
> System.out.println("category : " + values.get("category")); 
> 
> This is a snippet from the debug output : 
> 
> [title, categoryId] 
> {title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]} 
> title : null 
> category : null 
> 
> Thanks again! 
> 
> Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit : 
> 
>     Simply specify the fields that you are interested in, in the 

query and you are good to go.

> 
>     [1]

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>

>     <

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>>

> 
>     On 12/2/14 12:52 PM, Elias Abou Haydar wrote: 
>     > I'm trying to write a mapreduce job where I can query 

elasticsearch so it can return to me specific fields. Is there any

>     > way to do that? 
>     > 
>     > My mapping contains about 30 fields and I will need just 4 

of them ("_id","title","description","category")

>     > 
>     > The way I was doing it is to process each answer to get 

those fields, but I'm looking for a cleaner way to do that.

>     > 
>     > Any help or suggestion is appreciated. 
>     > 
>     > Thanks! 
>     > 
>     > -- 
>     > 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

>     >elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:> <javascript:>

<javascript:>>. 
>     > To view this discussion on the web visit 
>     >

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>>

>     > <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>>.

> 
>     > For more options, visithttps://groups.google.com/d/optout <

http://groups.google.com/d/optout> <https://groups.google.com/d/optout

<https://groups.google.com/d/optout>>. 
> 
>     -- 
>     Costin 
> 
> -- 
> 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

>elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:> <javascript:>>.

> To view this discussion on the web visit 
>

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com>

> <

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>>.

> For more options, visithttps://groups.google.com/d/optout <

https://groups.google.com/d/optout>.

-- 
Costin 

--
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
elasticsearc...@googlegroups.com <javascript:> <mailto:
elasticsearch+unsubscribe@googlegroups.com <javascript:>>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com

<
https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com?utm_medium=email&utm_source=footer>.

For more options, visit https://groups.google.com/d/optout.

--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/83dfbb85-53e3-47ca-a27b-e0410f4a0565%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ok actually Strings() returns the String array that has the contents and
that solved my problem.

Thanks again Costin! :slight_smile:

Le mercredi 3 décembre 2014 16:29:38 UTC+1, Elias Abou Haydar a écrit :

I've tried to call toStrings()
I got this :
title : [Ljava.lang.String;@35112ff7

with the get(), i'm getting this:
title : [Lorg.apache.hadoop.io.Writable;@666f5678

Le mercredi 3 décembre 2014 16:21:40 UTC+1, Costin Leau a écrit :

You're getting back an array ([Samsung EF-C....]) - a Writable wrapper
around org.hadoop.io.ArrayWritable (to actually
allow it to be serialized).
So call toStrings() or get() to get its content.

On 12/3/14 3:30 PM, Elias Abou Haydar wrote:

I've tried that. It returns a
org.elasticsearch.hadoop.mr.WritableArrayWritable object. How can I get my
field content
out of that?

Le mercredi 3 décembre 2014 14:10:24 UTC+1, Costin Leau a écrit :

That's because your MapWritables doesn't use Strings as keys but 

rather org.apache.hadoop.io.Text

In other words, you can see the data is in the map however you 

cannot retrieve it since you are using the wrong key

(try 
inspecting the map object types). 

Try values.get(new Text("title")) 


On 12/3/14 3:04 PM, Elias Abou Haydar wrote: 
> That works fine for me thank you! But I'd also wanted to be able 

to build and object from the MapWritable values in the

> mapper. 
> 
> Consider values as MapWritable object. 
> When I try to get a specified value from values.get("title") per 

example the returning value is null but the field

> exists in the values.keySet() 
> 
> Considering the following code : 
> 
> System.out.println(values.keySet()); 
> System.out.println(values.toString()); 
> System.out.println("title : " + values.get("title")); 
> System.out.println("category : " + values.get("category")); 
> 
> This is a snippet from the debug output : 
> 
> [title, categoryId] 
> {title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]} 
> title : null 
> category : null 
> 
> Thanks again! 
> 
> Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit : 
> 
>     Simply specify the fields that you are interested in, in the 

query and you are good to go.

> 
>     [1]

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>

>     <

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>>

> 
>     On 12/2/14 12:52 PM, Elias Abou Haydar wrote: 
>     > I'm trying to write a mapreduce job where I can query 

elasticsearch so it can return to me specific fields. Is there any

>     > way to do that? 
>     > 
>     > My mapping contains about 30 fields and I will need just 4 

of them ("_id","title","description","category")

>     > 
>     > The way I was doing it is to process each answer to get 

those fields, but I'm looking for a cleaner way to do that.

>     > 
>     > Any help or suggestion is appreciated. 
>     > 
>     > Thanks! 
>     > 
>     > -- 
>     > 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

>     >elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:>

<javascript:>>. 
>     > To view this discussion on the web visit 
>     >

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>>

>     > <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>>.

> 
>     > For more options, visithttps://groups.google.com/d/optout <

http://groups.google.com/d/optout> <https://groups.google.com/d/optout

<https://groups.google.com/d/optout>>. 
> 
>     -- 
>     Costin 
> 
> -- 
> 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

>elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:>>.

> To view this discussion on the web visit 
>

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com>

> <

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>>.

> For more options, visithttps://groups.google.com/d/optout <

https://groups.google.com/d/optout>.

-- 
Costin 

--
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
elasticsearc...@googlegroups.com <mailto:
elasticsearch+unsubscribe@googlegroups.com>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com

<
https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com?utm_medium=email&utm_source=footer>.

For more options, visit https://groups.google.com/d/optout.

--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/86ed3c43-2189-4be8-8e19-c3ea986602fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I'm not sure what you are expecting since the results are as expected. See the javadocs [1] for ArrayWritable.
toStrings() returns a String while get() a Writable. In other words you get an array of Strings and Writables and
neither
implements toString natively.
To get the actual content you have to iterate through the array - to simply print out the array content try
java.util.Arrays.toString().

The above is just MapReduce/Java code - fairly straight-forward. I strongly recommend going through the javadocs and
playing around with the APIs;
if that is not appealing to you than potentially using a higher level abstraction (like Cascading) would make sense over
Map/Reduce...

[1] ArrayWritable (Apache Hadoop Main 3.3.6 API)

On 12/3/14 5:29 PM, Elias Abou Haydar wrote:

I've tried to call toStrings()
I got this :
title : [Ljava.lang.String;@35112ff7

with the get(), i'm getting this:
title : [Lorg.apache.hadoop.io.Writable;@666f5678

Le mercredi 3 décembre 2014 16:21:40 UTC+1, Costin Leau a écrit :

You're getting back an array ([Samsung EF-C....]) - a Writable wrapper around org.hadoop.io.ArrayWritable (to actually
allow it to be serialized).
So call toStrings() or get() to get its content.


On 12/3/14 3:30 PM, Elias Abou Haydar wrote:
> I've tried that. It returns a org.elasticsearch.hadoop.mr.WritableArrayWritable object. How can I get my field content
> out of that?
>
> Le mercredi 3 décembre 2014 14:10:24 UTC+1, Costin Leau a écrit :
>
>     That's because your MapWritables doesn't use Strings as keys but rather org.apache.hadoop.io.Text
>     In other words, you can see the data is in the map however you cannot retrieve it since you are using the wrong key
>     (try
>     inspecting the map object types).
>
>     Try values.get(new Text("title"))
>
>
>     On 12/3/14 3:04 PM, Elias Abou Haydar wrote:
>     > That works fine for me thank you! But I'd also wanted to be able to build and object from the MapWritable values in the
>     > mapper.
>     >
>     > Consider values as MapWritable object.
>     > When I try to get a specified value from values.get("title") per example the returning value is null but the field
>     > exists in the values.keySet()
>     >
>     > Considering the following code :
>     >
>     > System.out.println(values.keySet());
>     > System.out.println(values.toString());
>     > System.out.println("title : " + values.get("title"));
>     > System.out.println("category : " + values.get("category"));
>     >
>     > This is a snippet from the debug output :
>     >
>     > [title, categoryId]
>     > {title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]}
>     > title : null
>     > category : null
>     >
>     > Thanks again!
>     >
>     > Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit :
>     >
>     >     Simply specify the fields that you are interested in, in the query and you are good to go.
>     >
>     >     [1]http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html>
>     <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html>>
>     >     <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html>
>     <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html>>>
>     >
>     >     On 12/2/14 12:52 PM, Elias Abou Haydar wrote:
>     >     > I'm trying to write a mapreduce job where I can query elasticsearch so it can return to me specific fields. Is there any
>     >     > way to do that?
>     >     >
>     >     > My mapping contains about 30 fields and I will need just 4 of them ("_id","title","description","category")
>     >     >
>     >     > The way I was doing it is to process each answer to get those fields, but I'm looking for a cleaner way to do that.
>     >     >
>     >     > Any help or suggestion is appreciated.
>     >     >
>     >     > Thanks!
>     >     >
>     >     > --
>     >     > 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
>     >     >elasticsearc...@googlegroups.com <javascript:> <mailto:elasticsearch+unsubscribe@googlegroups.com <javascript:>
<javascript:>
>     <javascript:>>.
>     >     > To view this discussion on the web visit
>     >     >https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>
>     <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>>
>     >     <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>
>     <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>>>
>     >     > <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>

>
>     >     <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>>>.

>
>     >
>     >     > For more options, visithttps://groups.google.com/d/optout <http://groups.google.com/d/optout> <http://groups.google.com/d/optout
<http://groups.google.com/d/optout>> <https://groups.google.com/d/optout <https://groups.google.com/d/optout>
>     <https://groups.google.com/d/optout <https://groups.google.com/d/optout>>>.
>     >
>     >     --
>     >     Costin
>     >
>     > --
>     > 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
>     >elasticsearc...@googlegroups.com <javascript:> <mailto:elasticsearch+unsubscribe@googlegroups.com <javascript:>
<javascript:>>.
>     > To view this discussion on the web visit
>     >https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com>
>     <https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com>>
>     > <https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>>>.

>
>     > For more options, visithttps://groups.google.com/d/optout <http://groups.google.com/d/optout> <https://groups.google.com/d/optout
<https://groups.google.com/d/optout>>.
>     --
>     Costin
>
> --
> 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
>elasticsearc...@googlegroups.com <javascript:> <mailto:elasticsearch+unsubscribe@googlegroups.com <javascript:>>.
> To view this discussion on the web visit
>https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com
<https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com>
> <https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com?utm_medium=email&utm_source=footer>>.

> For more options, visithttps://groups.google.com/d/optout <https://groups.google.com/d/optout>.

--
Costin

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/83dfbb85-53e3-47ca-a27b-e0410f4a0565%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/83dfbb85-53e3-47ca-a27b-e0410f4a0565%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout.

--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/547F313C.5090601%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

I have actually went through the API and I get the big picture now.

I appreciate your help. Thanks! :slight_smile:

Le mercredi 3 décembre 2014 16:50:33 UTC+1, Costin Leau a écrit :

I'm not sure what you are expecting since the results are as expected. See
the javadocs [1] for ArrayWritable.
toStrings() returns a String while get() a Writable. In other words
you get an array of Strings and Writables and
neither
implements toString natively.
To get the actual content you have to iterate through the array - to
simply print out the array content try
java.util.Arrays.toString().

The above is just MapReduce/Java code - fairly straight-forward. I
strongly recommend going through the javadocs and
playing around with the APIs;
if that is not appealing to you than potentially using a higher level
abstraction (like Cascading) would make sense over
Map/Reduce...

[1]
ArrayWritable (Apache Hadoop Main 3.3.6 API)

On 12/3/14 5:29 PM, Elias Abou Haydar wrote:

I've tried to call toStrings()
I got this :
title : [Ljava.lang.String;@35112ff7

with the get(), i'm getting this:
title : [Lorg.apache.hadoop.io.Writable;@666f5678

Le mercredi 3 décembre 2014 16:21:40 UTC+1, Costin Leau a écrit :

You're getting back an array ([Samsung EF-C....]) - a Writable 

wrapper around org.hadoop.io.ArrayWritable (to actually

allow it to be serialized). 
So call toStrings() or get() to get its content. 


On 12/3/14 3:30 PM, Elias Abou Haydar wrote: 
> I've tried that. It returns a 

org.elasticsearch.hadoop.mr.WritableArrayWritable object. How can I get my
field content

> out of that? 
> 
> Le mercredi 3 décembre 2014 14:10:24 UTC+1, Costin Leau a écrit : 
> 
>     That's because your MapWritables doesn't use Strings as keys 

but rather org.apache.hadoop.io.Text

>     In other words, you can see the data is in the map however you 

cannot retrieve it since you are using the wrong key

>     (try 
>     inspecting the map object types). 
> 
>     Try values.get(new Text("title")) 
> 
> 
>     On 12/3/14 3:04 PM, Elias Abou Haydar wrote: 
>     > That works fine for me thank you! But I'd also wanted to be 

able to build and object from the MapWritable values in the

>     > mapper. 
>     > 
>     > Consider values as MapWritable object. 
>     > When I try to get a specified value from values.get("title") 

per example the returning value is null but the field

>     > exists in the values.keySet() 
>     > 
>     > Considering the following code : 
>     > 
>     > System.out.println(values.keySet()); 
>     > System.out.println(values.toString()); 
>     > System.out.println("title : " + values.get("title")); 
>     > System.out.println("category : " + values.get("category")); 
>     > 
>     > This is a snippet from the debug output : 
>     > 
>     > [title, categoryId] 
>     > {title=[Samsung EF-CI950BCEGWW S View], categoryId=[3485]} 
>     > title : null 
>     > category : null 
>     > 
>     > Thanks again! 
>     > 
>     > Le mardi 2 décembre 2014 12:36:57 UTC+1, Costin Leau a écrit 

:

>     > 
>     >     Simply specify the fields that you are interested in, in 

the query and you are good to go.

>     > 
>     >     [1]

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>

>     <

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>>

>     >     <

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>

>     <

Elasticsearch Platform — Find real-time answers at scale | Elastic

<

Elasticsearch Platform — Find real-time answers at scale | Elastic>>>

>     > 
>     >     On 12/2/14 12:52 PM, Elias Abou Haydar wrote: 
>     >     > I'm trying to write a mapreduce job where I can query 

elasticsearch so it can return to me specific fields. Is there any

>     >     > way to do that? 
>     >     > 
>     >     > My mapping contains about 30 fields and I will need 

just 4 of them ("_id","title","description","category")

>     >     > 
>     >     > The way I was doing it is to process each answer to 

get those fields, but I'm looking for a cleaner way to do that.

>     >     > 
>     >     > Any help or suggestion is appreciated. 
>     >     > 
>     >     > Thanks! 
>     >     > 
>     >     > -- 
>     >     > 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

>     >     >elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:> <javascript:>

<javascript:> 
>     <javascript:>>. 
>     >     > To view this discussion on the web visit 
>     >     >

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>>

>     >     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com>>>

>     >     > <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>

> 
>     >     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/ac512248-b3fe-4023-b28e-a4263ae720ec%40googlegroups.com?utm_medium=email&utm_source=footer>>>>.

> 
>     > 
>     >     > For more options, visithttps://

groups.google.com/d/optout http://groups.google.com/d/optout <
http://groups.google.com/d/optout

<http://groups.google.com/d/optout>> <

https://groups.google.com/d/optout https://groups.google.com/d/optout

>     <https://groups.google.com/d/optout <

https://groups.google.com/d/optout>>>.

>     > 
>     >     -- 
>     >     Costin 
>     > 
>     > -- 
>     > 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

>     >elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:> <javascript:>

<javascript:>>. 
>     > To view this discussion on the web visit 
>     >

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com>

>     <

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com>>

>     > <

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>

>     <

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/0b096d2b-4dab-443a-b9ca-cd249a0523d8%40googlegroups.com?utm_medium=email&utm_source=footer>>>.

> 
>     > For more options, visithttps://groups.google.com/d/optout <

http://groups.google.com/d/optout> <https://groups.google.com/d/optout

<https://groups.google.com/d/optout>>. 
>     -- 
>     Costin 
> 
> -- 
> 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

>elasticsearc...@googlegroups.com <javascript:> <mailto:

elasticsearch+unsubscribe@googlegroups.com <javascript:> <javascript:>>.

> To view this discussion on the web visit 
>

https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com

<

https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com>

> <

https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com?utm_medium=email&utm_source=footer

<

https://groups.google.com/d/msgid/elasticsearch/0362a051-0e5c-4861-96fd-290d131ce726%40googlegroups.com?utm_medium=email&utm_source=footer>>.

> For more options, visithttps://groups.google.com/d/optout <

https://groups.google.com/d/optout>.

-- 
Costin 

--
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
elasticsearc...@googlegroups.com <javascript:> <mailto:
elasticsearch+unsubscribe@googlegroups.com <javascript:>>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/elasticsearch/83dfbb85-53e3-47ca-a27b-e0410f4a0565%40googlegroups.com

<
https://groups.google.com/d/msgid/elasticsearch/83dfbb85-53e3-47ca-a27b-e0410f4a0565%40googlegroups.com?utm_medium=email&utm_source=footer>.

For more options, visit https://groups.google.com/d/optout.

--
Costin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/892758db-bcfe-4871-bb2c-47fbf33e0bb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.