Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Can't handle _source-fields with point (".") inside field-name #89

Open
chris-searchit opened this issue Oct 21, 2020 · 6 comments
Open

Comments

@chris-searchit
Copy link

chris-searchit commented Oct 21, 2020

String[] fieldNames = spec.field.split("\\.");
Object value = sourceAsMap;
// Descend into maps.
for (String fieldName : fieldNames) {
if (Map.class.isInstance(value)) {
value = ((Map<?, ?>) value).get(fieldName);
if (value == null) {
// No such key.
logger.warn(
"Cannot find field named '{}' from spec: '{}'", fieldName, spec.field);
break outer;
}
} else {
logger.warn("Field is not a map: {} in spec.: {}", fieldName, spec.field);
break outer;
}

_source-fields with point (".") inside field-name are not correct handled.
E.g. following field_mapping will fail, because point inside "text.title"

    "field_mapping": {
      "title"  : ["_source.text.title"]
    }
@dweiss
Copy link
Member

dweiss commented Oct 22, 2020

I'll take a look. If you can beat me to it and provide a patch, it'd be great.

@dweiss
Copy link
Member

dweiss commented Nov 4, 2020

Sorry, took a while. Indeed, the path within _source is evaluated with a simple dot-delimited pattern. I wonder how to elegantly solve it though... With some kind of escaping? Or maybe with quoted-path segments?

   "field_mapping": {
      "title"  : ['_source."text.title"']
    }

@chris-searchit
Copy link
Author

That seems to be a solution. Unfortunately i can't get unit tests running to provide a patch, sorry.

@dweiss
Copy link
Member

dweiss commented Nov 9, 2020

The tests pass for me on master (windows and Linux) - strange that you can't get them to work. I do have this in the back of my mind but I admit it is of low priority. Will get there, eventually. Thanks for reporting.

@chris-searchit
Copy link
Author

Which JDK version are you using?

@dweiss
Copy link
Member

dweiss commented Nov 9, 2020

Elasticsearch plugin will enforce the minimum JDK version for each ES release. At the moment master is on 7.9.3 and I'm using JDK 14.0.1. gradlew check passes just fine. What's the error you're getting?

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

No branches or pull requests

2 participants