-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Issue #849 reported that MultiGet was ignoring _source fields. The issue has since been closed with a supposed fix pushed to develop. Having tested that fix, I can confirm that functionality is still missing.
Here's a sample which demonstrates the issue (references latest develop sources):
class Program
{
static void Main(string[] args)
{
const string serverUrl = "http://localhost:9200";
const string indexName = "test";
const bool resetAll = false;
var guids = new[] {
new Guid("16b006aa-416f-42e4-801c-7f61f6d74294"),
new Guid("eb2e4f76-a697-4690-b339-cf923eda2c92"),
new Guid("494d59fa-965d-4c84-96e3-ac617a7536ca"),
};
var client = new ElasticClient(new ConnectionSettings(new Uri(serverUrl))
.SetTimeout(15000)
.SetDefaultIndex(indexName));
if (resetAll || !client.IndexExists(x => x.Index(indexName)).Exists)
{
ResetIndex(client, indexName, guids);
}
var response = client.MultiGet(s => s
.GetMany<Thing>(guids.Select(x => x.ToString()))
.SourceInclude<Thing>(x => x.Id, x => x.Name));
DisplayThings(response.Documents.Select(x => x.Source).Cast<Thing>());
Console.ReadKey();
}
static void DisplayThings(IEnumerable<Thing> things)
{
foreach (var item in things)
{
Console.WriteLine("{1}{0}{1}{1}{2}", item, Environment.NewLine, new String('*', 50));
}
}
static void ResetIndex(IElasticClient client, string indexName, IList<Guid> guids)
{
Action fnCreate = () =>
{
client.CreateIndex(x => x.Index(indexName));
client.Map<Thing>(x => x.MapFromAttributes());
};
if (client.IndexExists(x => x.Index(indexName)).Exists)
{
client.DeleteIndex(x => x.Index(indexName));
fnCreate();
}
else
{
fnCreate();
}
var items = new[] {
new Thing() {
Id = guids[0],
Name = "Thing 1",
Description = "This is a description for thing 1"
},
new Thing() {
Id = guids[1],
Name = "Thing 2",
Description = "This is a description for thing 2"
},
new Thing() {
Id = guids[2],
Name = "Thing 3",
Description = "This is a description for thing 3"
},
};
client.IndexMany(items);
}
[ElasticType(IdProperty = "Id", Name = "thing")]
public class Thing
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public override string ToString()
{
return String.Format("Id: {0}{3}" +
"Name: {1}{3}" +
"Description: {2}",
Name, Id, Description ?? "<null>", Environment.NewLine);
}
}
}
Metadata
Metadata
Assignees
Labels
No labels