Description
Elastic.Clients.Elasticsearch version: 8.15.10
Elasticsearch version: 8.15.1
.NET runtime version: 8.0
Operating system version: Windows 12
Description of the problem including expected versus actual behavior:
A clear and concise description of what the bug is.
In the previous NEST client, I could issue a query like:
search = search.Source(s => s
.Includes(i => i
.Fields(
f => f.Id,
f => f.Title
)
)
);
and the resulting json would look like:
{
"aggs": {
"category": {
"terms": {
"field": "category",
"min_doc_count": 0,
"size": 2147483647
}
},
"stream": {
"terms": {
"field": "stream",
"min_doc_count": 0,
"size": 2147483647
}
},
"entity": {
"terms": {
"field": "entity",
"min_doc_count": 0,
"size": 2147483647
}
},
"folder": {
"terms": {
"field": "folder",
"min_doc_count": 0,
"size": 2147483647
}
},
"label": {
"terms": {
"field": "label",
"min_doc_count": 0,
"size": 2147483647
}
},
"language": {
"terms": {
"field": "language",
"min_doc_count": 0,
"size": 2147483647
}
},
"metadata": {
"terms": {
"field": "metadata",
"min_doc_count": 0,
"size": 2147483647
}
},
"rating": {
"terms": {
"field": "rating",
"min_doc_count": 0,
"size": 2147483647
}
},
"tag": {
"terms": {
"field": "tag",
"min_doc_count": 0,
"size": 2147483647
}
}
},
"from": 0,
"query": {
"query_string": {
"default_operator": "and",
"query": "projectId:2334"
}
},
"size": 1000,
"sort": [
{
"approved": {
"order": "desc"
}
},
{
"_score": {
"order": "desc"
}
},
{
"rating": {
"order": "desc"
}
}
],
"_source": {
"includes": [
"id",
"title"
]
},
"track_total_hits": true
}
In the new ElasticSearch client (after searching through various issues, as well as the code), I am trying to replicate this like the following, but am not getting the includes in the resulting json.
search = search.SourceIncludes(Fields.FromFields([
Infer.Field<SearchAlert>(f => f.Id), Infer.Field<SearchAlert>(f => f.Title)
]));
{
"aggregations": {
"category": {
"terms": {
"field": "category",
"min_doc_count": 0,
"size": 2147483647
}
},
"stream": {
"terms": {
"field": "stream",
"min_doc_count": 0,
"size": 2147483647
}
},
"entity": {
"terms": {
"field": "entity",
"min_doc_count": 0,
"size": 2147483647
}
},
"folder": {
"terms": {
"field": "folder",
"min_doc_count": 0,
"size": 2147483647
}
},
"label": {
"terms": {
"field": "label",
"min_doc_count": 0,
"size": 2147483647
}
},
"language": {
"terms": {
"field": "language",
"min_doc_count": 0,
"size": 2147483647
}
},
"metadata": {
"terms": {
"field": "metadata",
"min_doc_count": 0,
"size": 2147483647
}
},
"rating": {
"terms": {
"field": "rating",
"min_doc_count": 0,
"size": 2147483647
}
},
"tag": {
"terms": {
"field": "tag",
"min_doc_count": 0,
"size": 2147483647
}
}
},
"from": 0,
"query": {
"query_string": {
"default_operator": "and",
"query": "projectId:2423"
}
},
"size": 1000,
"sort": [
{
"approved": {
"order": "desc"
}
},
{
"_score": {
"order": "desc"
}
},
{
"rating": {
"order": "desc"
}
}
],
"track_total_hits": true
}
Any help would be appreciated as this is one of the last pieces of our client that needs to be updated, and we don't want to bring back all fields from our Search document, but still want to rely upon it for reference within various other Expressions.