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

I appreciate your help. Thanks! :)

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] 
> https://hadoop.apache.org/docs/current/api/org/apache/hadoop/io/ArrayWritable.html
>  
>
> 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 
> >     >     >     >[email protected] <javascript:> <mailto:
> [email protected] <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 
> >     >     >[email protected] <javascript:> <mailto:
> [email protected] <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 
> >     >[email protected] <javascript:> <mailto:
> [email protected] <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 
> > [email protected] <javascript:> <mailto:
> [email protected] <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 [email protected].
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.

Reply via email to