Esempio n. 1
0
        public Subset CreateByTag(string tagId, string tagField)
        {
            var docQuery  = queryFactory.GetDocumentQuery(_indexName);
            var wordQuery = queryFactory.GetWordQuery(_indexName);
            var docs      = docQuery.GetByTagId(tagId, tagField, DocumentQuery.GetDocumentElasticFields(new[] { DocumentElastic.IdField }));

            Func <string, bool> isAttachmentField = (field) => attachmentFields.Any(attachmentField =>
                                                                                    string.Equals(attachmentField, field, StringComparison.OrdinalIgnoreCase));

            var fields = _textFields
                         .Select(field => isAttachmentField(field) ? $"{field}.content" : field)
                         .ToList();

            var wwo = wordQuery.GetWordsWithOccurences(docs.Select(d => d.Id).ToList(), fields, _nGramCount);

            var subset = new Subset
            {
                AllWordsOccurencesSumInCorpus = _allWordsOccurences,
                AllWordsOccurencesSumInTag    = wwo.Sum(w => w.Value.Tag),
                WordsWithOccurences           = wwo
            };

            return(subset);
        }