How to keep relations between fields, when using stored fields and Fields query?

Hi

I have a large document, where I only wish to retrieve a couple of the fields.
The solution I have found to this problem, is to use stored fields.
I know _source filtering is a possibility, but this is very slow, since it has to parse the entire document, before it can return the relevant fields.
(https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-store.html)

Some of the data I wish to retrieve is mapped in objects.
I.e

{  
   "mappings":{  
   "properties":{  
         "person":{  
           "properties":{  
              "firstName":{  
                  "type":"text",
                  "store":true
               },
               "lastName":{  
                  "type":"text",
                  "store":true
               }
            }
         }
      }
   }
}

My problem is that when retrieving stored fields, by using "Fields" in my query (I am using elastic v.1.7.5), I get an array containing the firstNames and an array containing the lastNames.
I understand why this is happening, but is there any way to keep the relation between the firstName and the lastName when using stored fields?

Or are there any other technique to solve this problem?

My first thought was to use nested objects, but they cant be accessed outside the nested scope, and thus cant be accessed through "Fields" - (https://www.elastic.co/guide/en/elasticsearch/reference/1.7/mapping-nested-type.html)

The solution I have now is thus to use denormalization, by making an extra field called "fullname" containing both firstName and LastName, using ie a json string, and then make this field stored, which results in an array of fullNames.
This is however not optimal, since my objects have multiple properties, and it is not always the same combination of properties I wish to retrieve.
So I feel I am missing something.

To sum up, how do I keep relations between fields, when using stored fields, to make queries on large documents more efficient?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.