Skip to content

Fixes #4047 - Empty objects are not stored in _source when an include/ex... #4080

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

Closed
wants to merge 4 commits into from

Conversation

RobCherry
Copy link
Contributor

...clude list is present

Closes #4047

This was originally being tracked by pull request #4048. I closed that pull request because it was sloppy.

I am uncertain about the behavior for handling includes/excludes with empty objects and wildcards, so I added tests to cover the following cases, but please let me know if you think the results are incorrect...

Given

{
  "object1": { },
  "object2": { }
}

And a mapping

{
  ...
  {
    "_source" : {
      "excludes": "object1.*,
      "includes": "object2.*"
    }
  }
}

Results in a filtered source of

{
  "object1": { },
}

However, if given

{
  "object1": {
    "key1": "value1"
   },
  "object2": {
    "key2": "value2"
  }
}

and the same mapping, the filtered source would be

{
  "object2": {
    "key2": "value2"
  }
}

@ghost ghost assigned bleskes Nov 4, 2013
@bleskes
Copy link
Contributor

bleskes commented Nov 11, 2013

Hi,

Once again - thx for looking into this. I don't think we should make a distinction between having an obj.* and obj.f as excludes (or includes for that matter) where f is the only field in that object. Also, for excludes, we always make to remove an object that became empty after applying filters to it's content. With includes, we do not return objects if they have no matching properties.

So with this object, I think this is what it should do:

{
   "object1": { "f1": 1},
   "object2": { "f2": 2},
   "object3": { }
}

Then exclude=["object1.*"] should return

{
   "object2": { "f2": 2},
   "object3": { }
}

Also,
include=["object3.*"] should return (because the filters found nothing):

{}

while include=["object3"] returns

{ "object3": {} }

and for your example, with the following object:

{
  "object1": { },
  "object2": { }
}

A mapping with { "excludes": "object1.*, "includes": "object2.*" } should result in:

{}

Makes sense?

@RobCherry
Copy link
Contributor Author

@bleskes I believe this will take care of the use case you outlined.

@bleskes
Copy link
Contributor

bleskes commented Nov 22, 2013

Thanks @RobCherry , will look at it asap.

}
}
if (excluded) {
if (Regex.simpleMatch(excludes, path)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@bleskes
Copy link
Contributor

bleskes commented Nov 25, 2013

Hi,

Left some comments. Thanks again for looking into this, I know it can be very tricky to get it right. Also the extra tests are a great addition.

Cheers,
Boaz

@bleskes
Copy link
Contributor

bleskes commented Dec 2, 2013

Hi Rob,

Sorry for not looking at this. I was travelling the whole of last week. Back now and will pick it asap.

@RobCherry
Copy link
Contributor Author

Great. Let me know what you think about #4080 (comment)

@bleskes
Copy link
Contributor

bleskes commented Dec 4, 2013

Hi Rob,

I thought about this some more and I do think you have a point. However, that will be a bigger change and it will break backwards compatibility. I think suggest we do this in small steps - first solve the bug you've found and then open another issue to discuss the general behavior and wether we want to change it (with the next major version which is 1.0).

If you agree, here is my idea for solving the bug: let's change the internal filter function ( https://github.com/elasticsearch/elasticsearch/pull/4080/files#diff-85c60dcb441d2ac9b132d73b9b6d2bbbR143 ) to return a bool indicating whether it actually filtered something away. Then we can use the old code, but only skip empty objects if the recursive call actually filtered something. Note that this can happen if some elements did not match an include rule or if one element matched an exclude rule.

@RobCherry
Copy link
Contributor Author

I have opened #4491.

@bleskes
Copy link
Contributor

bleskes commented Dec 18, 2013

Hi Rob,

Do you still want on fixing this issue, while we resolve the discussion about the more general approach?

@RobCherry
Copy link
Contributor Author

I don't have time to work on this right now, it may be a few weeks before I can circle back. If it is still open when I get time to work on it I would be happy to make the recommended changes.

@bleskes
Copy link
Contributor

bleskes commented Jan 31, 2014

closing this one as well, as the issue is resolved: #4047

@bleskes bleskes closed this Jan 31, 2014
imotov added a commit that referenced this pull request May 9, 2018
Adds initial very minimal support for geo_shapes to SQL. For now, geoshapes are
converted into String instead of Geometry objects on the JDBC side and no effort
to parse the result is performed.

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

Successfully merging this pull request may close these issues.

Empty objects are not stored in _source when an include/exclude list is present
2 participants