List of dictionaries mapping error

I am using ES 7.15 and attempting to explicit map a list of dictionaries in an index. The goal is field for each doc something like:

"authors" : [
          {"name": "Mary", "org": "Havard"},
          {"name": "Joe", "org": "Yale"},

in order to achieve this, I've been explicitly setting the mapping of the index as follows:

	"properties": {
		"authors" : {
          "type": "nested"

but this results in the values of each field in the dictionaries being arrays/lists of a single string, rather than a string. For example:

"authors" : [
          {"name": ["Mary"], "org": ["Havard"]},
          {"name": ["Joe"], "org": ["Yale"]},

Not only is the mapping wrong, but I'm also unable to field search for those values in lists. For example, searching the field for "Mary" returns no results.

I've tried explicitly mapping each field within the dictionaries as text, but this doesn't change anything. The online documentation just says to map the field as nested.

Is there anyway to map a list of dictionaries without the fields as lists?

Are you using a nested query as well, when searching?

Also as a general tip, with questions like this it's super handy if you provide a replicable set of examples that people can just copy and paste into Dev Tools to copy what you are running, and then provide any suggestions :slight_smile:

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