Native script custom scoring: accessing nested document fields

Hello,

I am trying to use a native (Java) script to perform custom scoring of
documents in my index, using the CustomScore query.

One of the fields I am trying to access in Java is a nested document field
--- if I try to access it using

DocLookup doc = doc();
doc.get("pins.date_added");

I get an ElasticSearchIllegalArgumentException at /: No field found for []
in mapping with types []]; } exception, suggesting that the pins.date added
field is inaccessible --- even though I have set the store_in_parent
property to true.

What is the correct way of going about accessing such fields? Where, if
anywhere, should the include_in_parent property be declared (at the
property or type level?)

Here's the relevant part of my mapping:

'pins': {
'type': 'nested',

'include_in_parent': 'true',                                           
                                 
'properties': {                                                         
                                
     'date_added': {u'index': 'not_analyzed',                           
                                
                      'omit_norms': 'true',                             
                                
                      u'store': 'no',                                   
                                
                      u'term_vector': 'no',                             
                                
                      u'type': 'date',                                 
                                 
                      'include_in_parent': 'true',                     
                                 
                      u'format': u'dateOptionalTime'},                 
                                 
     'id': {u'index': 'not_analyzed',                                   
                                
              'omit_norms': 'true',                                     
                                
              u'store': 'yes',                                         
                                 
              u'term_vector': 'no',                                     
                                
              u'type': 'string'},                                       
                                
     'owner_id': {u'index': 'not_analyzed',                             
                                
                  'omit_norms': 'true',                                 
                                
                  u'store': 'yes',                                     
                                 
                  u'term_vector': 'no',                                 
                                
                  u'type': 'long'},                            

}

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

Update: the above is indeed the correct way to retrieve nested document
values (they will be returned as arrays). My problem was caused by an
unrelated mapping change.

The include_in_parent/include_in_root property should be set at the type
level, not at the property level.

Maciej

On Friday, June 21, 2013 11:03:30 AM UTC+1, Maciej Kula wrote:

Hello,

I am trying to use a native (Java) script to perform custom scoring of
documents in my index, using the CustomScore query.

One of the fields I am trying to access in Java is a nested document field
--- if I try to access it using

DocLookup doc = doc();
doc.get("pins.date_added");

I get an ElasticSearchIllegalArgumentException at /: No field found for
in mapping with types ]; } exception, suggesting that the pins.date added
field is inaccessible --- even though I have set the store_in_parent
property to true.

What is the correct way of going about accessing such fields? Where, if
anywhere, should the include_in_parent property be declared (at the
property or type level?)

Here's the relevant part of my mapping:

'pins': {
'type': 'nested',

'include_in_parent': 'true',                                           
                                 
'properties': {                                                       
                                  
     'date_added': {u'index': 'not_analyzed',                         
                                  
                      'omit_norms': 'true',                           
                                  
                      u'store': 'no',                                 
                                  
                      u'term_vector': 'no',                           
                                  
                      u'type': 'date',                                 
                                 
                      'include_in_parent': 'true',                     
                                 
                      u'format': u'dateOptionalTime'},                 
                                 
     'id': {u'index': 'not_analyzed',                                 
                                  
              'omit_norms': 'true',                                   
                                  
              u'store': 'yes',                                         
                                 
              u'term_vector': 'no',                                   
                                  
              u'type': 'string'},                                     
                                  
     'owner_id': {u'index': 'not_analyzed',                           
                                  
                  'omit_norms': 'true',                               
                                  
                  u'store': 'yes',                                     
                                 
                  u'term_vector': 'no',                               
                                  
                  u'type': 'long'},                            

}

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