I know this is an old thread but I am reviving it because the same problem has been causing me headaches.
Oren, you state that it is "by design" that when using Id from a transformer, we get the lower cased id stored in the index.
Main features of the Result Transformers are:
I. Stand-alone, separated from Index.
If I include the an Id property from my entity in the output of a transformation, it should return that property as it is in the entity.
to take a modification of the example on that documentation page, where I've added an Id property:
public class Order {
public string Id {get;set;}
public DateTime OrderedAt {get;set;}
public Status Status {get;set;}
public string CustomerId {get;set;}
public IList < OrderLine >
Lines {get;set;}
}
public class OrderStatisticsTransformer: AbstractTransformerCreationTask < Order > {
public OrderStatisticsTransformer() {
TransformResults = orders => from order in orders
select new {
order.Id,
order.OrderedAt,
order.Status,
order.CustomerId,
CustomerName = LoadDocument < Customer > (order.CustomerId).Name,
LinesCount = order.Lines.Count
};
}
}
the TransformResults function is explicitly referencing order.Id, which is a string property of the order object and not necessarily lowercase. It is extremely confusing for the transformer to return the lowercase __document_id value from the index. It simply is not what was asked for or referenced in the code.
Does order.CustomerId return lowercase? If so, is this true equally whether or not CustomerId is indexed? If the answer depends on whether or not it is indexed, then it seems wrong that the output of the transfomer should be dependent on whether or not the field is indexed and could be modified by changing the index, and again is contrary to the statement that it is "stand-alone,separated from Index.". If the answer is that it returns CustomerId in its original casing, regardless of whether or not it is indexed, then it seems wrong that there is different behaviour only for properties that happen to be named "Id".
Either way, I think the lowercase index values should be reserved for comparison during searching and not used for transformer output.