Skip to content

Reopen #858: MultiGet does not respect source filtering fields #1235

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
lakario opened this issue Feb 5, 2015 · 4 comments
Closed

Reopen #858: MultiGet does not respect source filtering fields #1235

lakario opened this issue Feb 5, 2015 · 4 comments

Comments

@lakario
Copy link

lakario commented Feb 5, 2015

#858 appears to have been regressed, as early as version 1.0.2:

Just verified locally under the exact same conditions as originally. I was using version 1.0.2, and since upgraded to 1.4.0.

Here's the NEST query:

Client.MultiGet(s =>
    s.GetMany<Performer>(termItems.Select(x => x.Term))
    .SourceInclude<Performer>(x => x.Id, x => x.Name)

And the generated request:

http://qual-elastic002:9200/_mget?source_include=id%2Cname
{
  "docs": [
    {
      "_index": "qual4-events014",
      "_type": "performer",
      "_id": "f6fc51e4-4198-4d32-a47a-4e0e17e025a3"
    },
    {
      "_index": "qual4-events014",
      "_type": "performer",
      "_id": "98d2b8dd-0de8-4dfa-87f8-716a880fa6e0"
    }
    /* etc... */
  ]
}

The expected request:

http://qual-elastic002:9200/_mget
{
  "docs": [
    {
      "_index": "qual4-events014",
      "_type": "performer",
      "_id": "f6fc51e4-4198-4d32-a47a-4e0e17e025a3",
      "_source": [ "id", "name" ]
    },
    {
      "_index": "qual4-events014",
      "_type": "performer",
      "_id": "98d2b8dd-0de8-4dfa-87f8-716a880fa6e0",
      "_source": [ "id", "name" ]
    }
    /* etc... */
  ]
}
@lakario lakario changed the title Regression: 858 Reopen #858: mget does not respect source filtering fields Feb 5, 2015
@lakario lakario changed the title Reopen #858: mget does not respect source filtering fields Reopen #858: MultiGet does not respect source filtering fields Feb 5, 2015
@gmarz
Copy link
Contributor

gmarz commented Feb 6, 2015

@lakario You're applying source at the query param level, hence the request url: http://qual-elastic002:9200/_mget?source_include=id%2Cname which applies source filtering for the entire request.

Instead, you want to set source filtering at the document level. The syntax is a bit different:

Client.MultiGet(s =>s
    .GetMany<Performer>(termItems.Select(x => x.Term), gm => gm
        .Source(src => src
            .Include("id", "name")
        )
    )
)

@lakario
Copy link
Author

lakario commented Feb 6, 2015

@gmarz The above signature doesn't seem to exist for me.

public MultiGetDescriptor GetMany<T>(IEnumerable<long> ids, Func<MultiGetOperationDescriptor<T>, long, MultiGetOperationDescriptor<T>> getSelector = null) where T : class;
public MultiGetDescriptor GetMany<T>(IEnumerable<string> ids, Func<MultiGetOperationDescriptor<T>, string, MultiGetOperationDescriptor<T>> getSelector = null) where T : class;

Also, your example does not take advantage of the type-safe expression syntax, which is what I am after.

@gmarz
Copy link
Contributor

gmarz commented Feb 6, 2015

Oops sorry, I left out the long argument in the lambda. It should be:

Client.MultiGet(s =>s
    .GetMany<Performer>(termItems.Select(x => x.Term), (gm, i) => gm
        .Source(src => src
            .Include(x => x.Id, x.Name)
        )
    )
)

Notice above, you can also use the expression form for your properties.

@lakario
Copy link
Author

lakario commented Feb 6, 2015

@gmarz Sure enough, that's what I was looking for. Thanks.

@lakario lakario closed this as completed Feb 6, 2015
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

No branches or pull requests

2 participants