Raven.Database.Indexing.FieldsToFetch.EnsureHasField C# (CSharp) Method

EnsureHasField() public method

public EnsureHasField ( string ensuredFieldName ) : void
ensuredFieldName string
return void
		public void EnsureHasField(string ensuredFieldName)
		{
			if (ensuredFieldNames == null)
				ensuredFieldNames = new HashSet<string>();
			ensuredFieldNames.Add(ensuredFieldName);
		}

Usage Example

Example #1
0
        protected override IndexQueryResult RetrieveDocument(Document document, FieldsToFetch fieldsToFetch, ScoreDoc score)
        {
            fieldsToFetch.EnsureHasField(Constants.ReduceKeyFieldName);
            if (fieldsToFetch.HasExplicitFieldsToFetch)
            {
                return(base.RetrieveDocument(document, fieldsToFetch, score));
            }
            var field = document.GetField(Constants.ReduceValueFieldName);

            if (field == null)
            {
                fieldsToFetch = fieldsToFetch.CloneWith(document.GetFields().Select(x => x.Name).ToArray());
                return(base.RetrieveDocument(document, fieldsToFetch, score));
            }
            var projection = RavenJObject.Parse(field.StringValue);

            if (fieldsToFetch.FetchAllStoredFields)
            {
                var fields = new HashSet <string>(document.GetFields().Select(x => x.Name));
                fields.Remove(Constants.ReduceKeyFieldName);
                var documentFromFields = new RavenJObject();
                AddFieldsToDocument(document, fields, documentFromFields);
                foreach (var kvp in projection)
                {
                    documentFromFields[kvp.Key] = kvp.Value;
                }
                projection = documentFromFields;
            }
            return(new IndexQueryResult
            {
                Projection = projection,
                Score = score.Score,
                ReduceVal = field.StringValue
            });
        }
All Usage Examples Of Raven.Database.Indexing.FieldsToFetch::EnsureHasField