Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent results when mixing fieldname: { fieldname: { and fieldname.fieldname for mapping and indexing #5972

Closed
brwe opened this issue Apr 29, 2014 · 2 comments
Assignees
Labels

Comments

@brwe
Copy link
Contributor

brwe commented Apr 29, 2014

The handling of objects in a mapping seems inconsistent. When adding fields with dots, for example afield.number, then, when indexing a document

"afield": {
    "number": 4
}

the type of "afield": { "number": is found correctly, but a second mapping for the object is added. This happens even if the indexing operation fails in case the type of "afield": { "number": does not correspond with "afield.number" as defined in the mapping.

An example is here: https://gist.github.com/brwe/11394327

There are two issue with this:

  1. In STEP 2 (indexing the object) the indexing operation is rejected but the mapping for the object is still added. I do not think this should be so (This might be related to #5798)
  2. It seems to me that when creating or merging mappings, it should be checked if pathes exist twice. For example, the following yields no error:
PUT /testindex/sometype/_mapping
{
   "sometype": {
      "properties": {
         "afield.number": {
            "type": "integer"
         },
         "afield.text": {
            "type": "string"
         },
         "afield": {
            "properties": {
               "number": {
                  "type": "string"
               }
            }
         }
      }
   }
}
@imotov
Copy link
Contributor

imotov commented Apr 30, 2014

It seems that during mapper lookup elasticsearch recognizes that fields with "." in them represent inner object fields, but during mapper creation it treats them as root level fields. Here is another example of this strange behavior that shows how elasticsearch treats such fields in case of dynamic mapping:

$ curl -XPUT localhost:9200/test/doc/1 -d '{"foo.bar": 10}'
{"_index":"test","_type":"doc","_id":"1","_version":1,"created":true}

$ curl -XPUT localhost:9200/test/doc/2 -d '{"foo": {"baz": "test"}}'
{"_index":"test","_type":"doc","_id":"2","_version":1,"created":true}

$ curl "localhost:9200/test/_mapping?pretty"
{
  "test" : {
    "mappings" : {
      "doc" : {
        "properties" : {
          "foo" : {
            "properties" : {
              "baz" : {
                "type" : "string"
              }
            }
          },
          "foo.bar" : {
            "type" : "long"
          }
        }
      }
    }
  }
}

@clintongormley
Copy link

Closing in favour of #6736

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants