Lucene.Net.Linq
Lucene.Net.Linq copied to clipboard
Array support
Are array properties supported? Seems no.
Lucene supports multiple field instances with the same name for a single doc. Is this feature supported in Lucene.Net.Linq?
Currently properties of type IEnumerable<T> are supported. To support more specific collections and arrays, changes will be required in FieldMappingInfoBuilder:58 and CollectionReflectionFieldMapper. Test cases can be added to FieldMappingInfoBuilderCollectionComplexTypeTests and/or FieldMappingInfoBuilderCollectionTests.
I'll keep this open until I get to it, or you can submit a PR if you'd like to see support sooner.
Thank you for fast response.
Using IEnumerable is okay for me.
However, is it possible to costruct a query on a multi-valued field to find documents having one of its values present in a fixed list of values? Actually, I would express it this way: obj.Tags.Intersect(values).Any().
You can test for the presence of a single value as in:
var result = from doc in documents where doc.Tags.Contains("c") select doc;
There is not currently a way to do an intersection with an arbitrary number of terms and I don't think Lucene supports this concept natively anyway. At best the LINQ library would probably have to transform doc.Tags.Intersect(values).Any() into doc.Tags.Contains(value[0]) || doc.Tags.Contains(value[1])
protected internal virtual IFieldMapper<T> ToFieldMapper()
{
ReflectionFieldMapper<T> inner = this.ToFieldMapperInternal();
Type collectionType;
if (FieldMappingInfoBuilder.IsCollection(this.propInfo.PropertyType, out collectionType))
return (IFieldMapper<T>) new CollectionReflectionFieldMapper<T>(inner, collectionType);
return (IFieldMapper<T>) inner;
}
This thing actually fails for string[] propperty, this.ToFieldMapperInternal(); must be called AFTER if (FieldMappingInfoBuilder.IsCollection(this.propInfo.PropertyType, out collectionType))
Moreover, there is not way I can ignore this property :(
I've tried map.Property(p => p.Photos).NotStored().NotIndexed(); but session still fails with:
System.NotSupportedException occurred
HResult=-2146233067
Message=Property Photos of type System.String[] cannot be converted from System.String
Source=Lucene.Net.Linq
StackTrace:
at Lucene.Net.Linq.Mapping.FieldMappingInfoBuilder.GetConverter(PropertyInfo p, Type type, FieldAttribute metadata)
at Lucene.Net.Linq.Fluent.PropertyMap`1.ResolveConverter()
at Lucene.Net.Linq.Fluent.PropertyMap`1.ToFieldMapperInternal()
at Lucene.Net.Linq.Fluent.PropertyMap`1.ToFieldMapper()
at Lucene.Net.Linq.Fluent.ClassMap`1.ToDocumentMapper()
at RestChild.Booking.TourIndexer.IndexAll() in c:\Projects\RestChild\RestChild.Booking\TourIndexer.cs:line 38
InnerException: