Esempio n. 1
0
        private BulkDescriptor ToElasticSearchDocs(IEnumerable <ValueSet> docs, string indexTarget)
        {
            var descriptor = new BulkDescriptor();


            foreach (var d in docs)
            {
                //this is just a dictionary
                var ad = new Document
                {
                    ["Id"] = d.Id,
                    [FormatFieldName(LuceneIndex.ItemIdFieldName)]   = d.Id,
                    [FormatFieldName(LuceneIndex.ItemTypeFieldName)] = d.ItemType,
                    [FormatFieldName(LuceneIndex.CategoryFieldName)] = d.Category
                };

                foreach (var i in d.Values)
                {
                    if (i.Value.Count > 0)
                    {
                        ad[FormatFieldName(i.Key)] = i.Value.Count == 1 ? i.Value[0]: i.Value;
                    }
                }
                var docArgs = new DocumentWritingEventArgs(d, ad);
                OnDocumentWriting(docArgs);
                descriptor.Index <Document>(op => op.Index(indexTarget).Document(ad).Id(d.Id));
            }

            return(descriptor);
        }
Esempio n. 2
0
 protected virtual void OnDocumentWriting(DocumentWritingEventArgs docArgs)
 {
     DocumentWriting?.Invoke(this, docArgs);
 }