Beispiel #1
0
        /* ========================================================================== Operations */

        public void AddDocument(IndexDocument document)
        {
            var versionId = document.GetIntegerValue(IndexFieldName.VersionId);

            var storedFields = document.Where(f => f.Store == IndexStoringMode.Yes).ToList();

            if (storedFields.Count > 0)
            {
                StoredData.Add(new Tuple <int, List <IndexField> >(versionId, storedFields));
            }

            foreach (var field in document)
            {
                var fieldName = field.Name;

                if (!IndexData.TryGetValue(fieldName, out var existingFieldData))
                {
                    existingFieldData = new Dictionary <string, List <int> >();
                    IndexData.Add(fieldName, existingFieldData);
                }

                var fieldValues = GetValues(field);

                foreach (var fieldValue in fieldValues)
                {
                    if (!existingFieldData.TryGetValue(fieldValue, out var versionIds))
                    {
                        versionIds = new List <int>();
                        existingFieldData.Add(fieldValue, versionIds);
                    }

                    versionIds.Add(versionId);
                }
            }
        }