Skip to content

Commit

Permalink
handle not list elements as simpler objects in index
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszbiel committed Sep 20, 2019
1 parent e3c1e70 commit 064f8a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private BulkDescriptor ToElasticSearchDocs(IEnumerable<ValueSet> 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);
Expand Down
10 changes: 5 additions & 5 deletions source/Novicell.Examine.ElasticSearch/Model/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class Document : Dictionary<string, object>
{
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;
Expand All @@ -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;
}

}
Expand All @@ -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;
}
Expand Down

0 comments on commit 064f8a0

Please sign in to comment.