Skip to content

Instantly share code, notes, and snippets.

@joafeldmann
Created February 13, 2014 13:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joafeldmann/f1deb5fc7bd43384472e to your computer and use it in GitHub Desktop.
Save joafeldmann/f1deb5fc7bd43384472e to your computer and use it in GitHub Desktop.
"attr": {
"type": "nested",
"properties": {
"key": {
"type": "string",
"index": "not_analyzed"
},
"text": {
"type": "string"
},
"integer": {
"type": "integer"
},
"float": {
"type": "float"
},
"date": {
"type": "date"
}
}
}
@joafeldmann
Copy link
Author

The mapping allows to store and query user defined values in ES. See example below. You should map the keys in a other databse system to the column name. (ID123 = "User1CustomField", ID456 = "User2CustomField")

{
    "attr" : [
        {
            "key": "ID123",
            "text": "Some text"
        },
        {
            "key": "ID456",
            "integer": 6
        }
    ]
}

you need to query the mapping with nested queries or filters. See
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-nested-filter.html

Double check your business requirements, since this really makes things complex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment