Comments (6)
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.
Implemented this for Get
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.
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.
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.
@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.
Just to confirm - routing isn't supported in multiget is it?
from elasticsearch-net.
Related Issues (20)
- [FEATURE] ElasticSearch 8 took away support for "Nullable" fields for Term Query HOT 9
- [FEATURE] Unable to use Term Query for Enums HOT 1
- SystemTextJsonSerializer.Serialize ignores SerializationFormatting HOT 1
- Creating an index with DynamicTemplates causes error HOT 4
- Cannot run knn query using elasticClient.RequestResponseSerializer HOT 5
- Unable to use descriptors to set Fields in MultiMatchQueryDescriptor query HOT 2
- Mystic MissingMethodException HOT 1
- A call to client.Cluster.StatsAsync fails with JSON serialization error HOT 2
- Provide a way to convert QueryDescriptor to Query (Elastic.Clients.Elasticsearch, 8.11.0) HOT 2
- Question: how to map the properties for a nested type - v8 HOT 1
- Add dotnet 6 TFM to reduce dependencies HOT 1
- Deprecation of old nugets and transfer of downloads HOT 1
- NEST does not work with .Net 8 HOT 2
- Add FilterPath to SearchRequestDescriptor HOT 1
- Decay functions score is missing on version 8 HOT 1
- Support AOT compilation HOT 9
- Can't find the Indices "ExistsAsync" method to check if index exists? HOT 1
- No documentation on how to Sort when not using the Fluent Api HOT 4
- Indicies.Get call fails to deserialize ICollections properly in the IndexRequest HOT 3
- Cannot sort with nullable long - "No mapping found"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-net.