diff --git a/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchIndex.cs b/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchIndex.cs index 25c3d1f..298cc12 100644 --- a/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchIndex.cs +++ b/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchIndex.cs @@ -241,7 +241,7 @@ private BulkDescriptor ToElasticSearchDocs(IEnumerable docs, string in foreach (var i in d.Values) { if (i.Value.Count > 0) - ad[FormatFieldName(i.Key)] = i.Value; + ad[FormatFieldName(i.Key)] = i.Value.Count == 1 ? i.Value[0]: i.Value; } var docArgs = new DocumentWritingEventArgs(d, ad); OnDocumentWriting(docArgs); diff --git a/source/Novicell.Examine.ElasticSearch/Model/Document.cs b/source/Novicell.Examine.ElasticSearch/Model/Document.cs index dc60728..746f499 100644 --- a/source/Novicell.Examine.ElasticSearch/Model/Document.cs +++ b/source/Novicell.Examine.ElasticSearch/Model/Document.cs @@ -10,9 +10,9 @@ public class Document : Dictionary { public Field GetField(string FieldName) { - if (this.ContainsKey(FieldName)) + if (ContainsKey(FieldName)) { - return new Field(FieldName,ToByteArray(this[FieldName]), Lucene.Net.Documents.Field.Store.YES); + return new Field(FieldName,Convert.ToString(this[FieldName]), Field.Store.YES, Field.Index.ANALYZED); } return null; @@ -21,9 +21,9 @@ public Field GetField(string FieldName) public void Add(Field field) { - if (this.ContainsKey(field.Name)) + if (ContainsKey(field.Name)) { - this[field.Name] = ByteArrayToObject(field.GetBinaryValue()); + this[field.Name] = field.StringValue; } } @@ -33,7 +33,7 @@ private Object ByteArrayToObject(byte[] arrBytes) BinaryFormatter binForm = new BinaryFormatter(); memStream.Write(arrBytes, 0, arrBytes.Length); memStream.Seek(0, SeekOrigin.Begin); - Object obj = (Object) binForm.Deserialize(memStream); + Object obj = binForm.Deserialize(memStream); return obj; }