Giter Site home page Giter Site logo

Comments (6)

Mpdreamz avatar Mpdreamz commented on May 17, 2024

It does when you do a search. In the case of get and multiget it doesn't.

Moving this to the top of my todo list.

On Aug 21, 2012, at 3:24 AM, danielduartef [email protected] wrote:

Hi,
Does NEST allow me to specify the fields to be retrieved in cases that I only need one or two fields in documents with a lot of other information?
In elasticsearch you can do something like:

curl -XGET 'http://localhost:9200/twitter/tweet/1?fields=title,content'

and

curl 'localhost:9200/_mget' -d '{
"docs" : [
{
"_index" : "test",
"_type" : "type",
"_id" : "1",
"fields" : ["field1", "field2"]
}
]
}'

It would be also good to allow me to provide the routing value:

curl -XGET 'http://localhost:9200/twitter/tweet/1?routing=kimchy'


Reply to this email directly or view it on GitHub.

from elasticsearch-net.

Mpdreamz avatar Mpdreamz commented on May 17, 2024

Implemented this for Get

ef2ca4d

var obj = elasticClient.Get<MyClass>(g=>g
    .Index("newindex")
    .Refresh()
    .Routing("routing")
    .ExecuteOnPrimary()
    .Id(1)
);

Leaving issue open since this still needs some integration tests and MultiGet needs to get support for this too.

from elasticsearch-net.

danielduartef avatar danielduartef commented on May 17, 2024

I am testing it, but it returns null every time if I specify the fields.

This will return an User object, not null:

User user = GetClient().Get<User>(g => g
            .Index(UserIndexName)
            .Type("user")
            .Id(userId)
        );

But this will return null every time:

User user = GetClient().Get<User>(g => g
            .Index(UserIndexName)
            .Type("user")
            .Id(userId)
            .Fields(u => u.Id, u => u.FacebookUID)
        );

from elasticsearch-net.

Mpdreamz avatar Mpdreamz commented on May 17, 2024

Thanks you for getting back to me, i was on holiday and then under the weather for a couple a days.

See i know i could not close this without some integration test :)

from elasticsearch-net.

Mpdreamz avatar Mpdreamz commented on May 17, 2024

@danielduartef sorry it took a while.

Get<T>(g=>g.Fields()) now no longer returns null.

Selecting a propery in an array i.e f=>f.Followers.First().FirstName will return data like this on elasticsearch'es side:

{
    "followers.firstName" : ["a", "b"]
}

instead of

{
    "followers" : [ { " firstName" : "a" }, { " firstName" : "a" } ]
}

this cannot be parsed back into the orginal object. Therefor a second method GetFieldSelection<T>(g=>g.Fields())) has been added that retuns FieldSelection<T> this has the following properties and methods:

  • Document the attempted parsed document, for most properties (not in arrays) this is sufficient
  • FieldValue(field) this will get the field data and cast it to K.

i.e fieldSelection.FieldValue<List<string>>(f=>f.Followers.First().FirstName)

See https://github.com/Mpdreamz/NEST/blob/d6ccb9118950b000b8fe9aaeb66adb36ed5bedca/src/Nest.Tests.Integration/Get/GetTests.cs#L45 For more info.

from elasticsearch-net.

james1ewis avatar james1ewis commented on May 17, 2024

Just to confirm - routing isn't supported in multiget is it?

from elasticsearch-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.