Skip to content

Confirming use of 'path' and 'index_name' in objects #2089

@clintongormley

Description

@clintongormley

Hiya

I'm using index_name and path in what feels like a hacky way, and just want to confirm that the way it works is intended, and won't change in the future.

I'm using a UID object to reference other objects stored in other types in ElasticSearch. That UID has an index, type and id attribute. I'd like to be able to access those as uid.index, uid.type etc, even thought the path may be:

{ employees: { managers: { uid: { index: 'foo' .....}}}}

I'm using a mapping like this:

curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1'  -d '
{
   "mappings" : {
      "test" : {
         "properties" : {
            "baz" : {
               "type" : "object",
               "properties" : {
                  "foo" : {
                     "type" : "object",
                     "properties" : {
                        "uid" : {
                           "path" : "just_name",
                           "type" : "object",
                           "properties" : {
                              "index" : {
                                 "index_name" : "uid.index",
                                 "type" : "string"
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   }
}
'

Note the index_name: "uid.index" and path: "just_name".

This mapping makes these fields queryable:

  • index
  • uid.index
  • baz.foo.uid.index

That suits my purposes, but I'd like to make sure that it isn't going to change :)

curl -XPUT 'http://127.0.0.1:9200/test/test/1?pretty=1'  -d '
{
   "baz" : {
      "foo" : {
         "uid" : {
            "index" : "bar"
         }
      }
   }
}
'

index = 1

curl -XGET 'http://127.0.0.1:9200/test/test/_count?pretty=1'  -d '
{
   "text" : {
      "index" : "bar"
   }
}
'

uid.index = 1

curl -XGET 'http://127.0.0.1:9200/test/test/_count?pretty=1'  -d '
{
   "text" : {
      "uid.index" : "bar"
   }
}
'

foo.uid.index = 0

curl -XGET 'http://127.0.0.1:9200/test/test/_count?pretty=1'  -d '
{
   "text" : {
      "foo.uid.index" : "bar"
   }
}
'

baz.foo.uid.index = 1

curl -XGET 'http://127.0.0.1:9200/test/test/_count?pretty=1'  -d '
{
   "text" : {
      "baz.foo.uid.index" : "bar"
   }
}
'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions