Пример #1
0
        public HelixAnalyzerService(XmlNode configNode, IDataSourceLocation dataSourceLocation,
                                    ICerberusVariablesReplacer variablesReplacer) : base(
                variablesReplacer)
        {
            _dataSourceLocation = dataSourceLocation;
            if (configNode == null)
            {
                return;
            }

            var analyzers = GetAnalyzers(configNode, out var provider);

            _logProvider = GetLogContainer(configNode);

            foreach (var node in analyzers)
            {
                var ruleProvider = RegisterRules(node);
                var type         = XmlActivator.GetType(node);
                if (type != null)
                {
                    provider.Register(type,
                                      () => XmlActivator.CreateInstance(type, node, new[] { provider, ruleProvider, _logProvider }),
                                      true);

                    if (provider.Resolve(type) is IHelixAnalyzer resolve)
                    {
                        Analyzers.Add(resolve);
                    }
                }
            }
        }
Пример #2
0
        public SolarSystem_Query()
        {
            Map = systems => from system in systems
                  select new
            {
                Name            = system.Name,
                NameExact       = system.Name,
                NamePartial     = system.Name,
                Economies       = system.Stations.SelectMany(x => x.Economy).Distinct(),
                Factions        = system.Factions.Select(x => x.Id),
                Attitude        = system.Stations.Where(x => x.Main).Select(x => x.Faction.Attitude).FirstOrDefault(),
                HasAlly         = system.Factions.Any(x => x.Attitude == FactionAttitude.Ally),
                HasCoordinates  = (system.Coordinates != null && !(system.Coordinates.X == 0 && system.Coordinates.Y == 0 && system.Coordinates.Z == 0)),
                Supply          = system.Stations.SelectMany(x => x.Commodities).Where(x => x.Supply != CommodityAvailability.None).Select(x => x.Type).Distinct(),
                Demand          = system.Stations.SelectMany(x => x.Commodities).Where(x => x.Demand != CommodityAvailability.None).Select(x => x.Type).Distinct(),
                PowerPlayLeader = system.PowerPlayLeader,
                PowerPlayState  = system.PowerPlayState,
                Outfitting      = system.Stations.Select(x => x.Outfitting).Distinct(),
                Groups          = system.Groups
            };

            Indexes.Add(x => x.Name, Raven.Abstractions.Indexing.FieldIndexing.Analyzed);
            Indexes.Add(x => x.NameExact, Raven.Abstractions.Indexing.FieldIndexing.Default);
            Indexes.Add(x => x.NamePartial, Raven.Abstractions.Indexing.FieldIndexing.Analyzed);

            Analyzers.Add(x => x.NamePartial, "Xemio.RavenDB.NGramAnalyzer.NGramAnalyzer,Xemio.RavenDB.NGramAnalyzer");
        }
Пример #3
0
        public Companies_SortByName()
        {
            Map = companies => from company in companies
                  select new { company.Name };

            Analyzers.Add(c => c.Name, typeof(PlCollationAnalyzer).ToString());
        }
Пример #4
0
        public void RegisterAnalyzer(ISharperCryptoApiAnalysisAnalyzer analyzer)
        {
            var index = Analyzers.IndexOf(analyzer);

            if (index < 0)
            {
                ThreadHelper.Generic.BeginInvoke(() => Analyzers.Add(analyzer));
            }
            else
            {
                ThreadHelper.Generic.BeginInvoke(() => Analyzers[index] = analyzer);
            }

            if (Settings.MutedAnalyzers.Contains((int)analyzer.AnalyzerId))
            {
                analyzer.IsMuted = true;
            }

            foreach (var report in analyzer.SupportedReports)
            {
                if (report.Equals(AnalysisReport.EmptyReport))
                {
                    continue;
                }
                ThreadHelper.Generic.BeginInvoke(() => Reports.Add(report));
            }
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T AddAnalyzer <T>() where T : TextTokenAnalyzer, new()
        {
            var analayzer = new T();

            Analyzers.Add(analayzer);
            return(analayzer);
        }
Пример #6
0
            public Object_ByName()
            {
                Map = objects => objects.Select(x => new { x.Name });

                Indexes.Add(x => x.Name, FieldIndexing.Analyzed);
                Analyzers.Add(x => x.Name, "Lucene.Net.Analysis.Standard.StandardAnalyzer");
            }
        public MessageDocument_Search()
        {
            Map = messageDocuments => from messageDocument in messageDocuments
                  select new
            {
                Any = new Object[]
                {
                    messageDocument.Body,
                    messageDocument.MessageTypes.Select(x => x.ClassName),
                    messageDocument.Headers.Select(x => x.Value),
                    messageDocument.AdditionalErrorStatus,
                    messageDocument.ApplicationId,
                    messageDocument.Id
                },
                messageDocument.Id,
                messageDocument.TimeSent,
                ClassName = messageDocument.MessageTypes.Select(x => x.ClassName),
                messageDocument.IsError,
                messageDocument.ApplicationId,
                Header = messageDocument.Headers.Select(x => x.Value),
                messageDocument.AdditionalErrorStatus
            };

            Sort(x => x.Id, SortOptions.String);
            Index(x => x.Any, FieldIndexing.Analyzed);
            Analyzers.Add(x => x.Any, "StandardAnalyzer");
        }
Пример #8
0
            public GetMultipleStringFieldsIndex()
            {
                Map = entities => from entity in entities
                      select new ReduceResult
                {
                    StringA = entity.StringA,
                    StringB = entity.StringB,
                    StringC = entity.StringC,
                    StringD = entity.StringD,
                    Sum     = 1
                };

                Reduce = results => from result in results
                         group result by new { result.StringA, result.StringB, result.StringC, result.StringD }
                into g
                    select new ReduceResult
                {
                    StringA = g.First().StringA,
                    StringB = g.First().StringB,
                    StringC = g.First().StringC,
                    StringD = g.First().StringD,
                    Sum     = g.Sum(x => x.Sum)
                };

                Analyzers.Add(c => c.StringA, typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).ToString());
                Analyzers.Add(c => c.StringB, typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).ToString());
                Analyzers.Add(c => c.StringC, typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).ToString());
                Analyzers.Add(c => c.StringD, typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).ToString());
                Indexes.Add(x => x.StringA, FieldIndexing.Search);

                Indexes.Add(x => x.StringB, FieldIndexing.Search);
                Indexes.Add(x => x.StringC, FieldIndexing.Search);
                Indexes.Add(x => x.StringD, FieldIndexing.Search);
            }
Пример #9
0
        public Companies_CustomAnalyzers()
        {
            Map = companies => from company in companies
                  select new {
                company.Name,
                company.Desc,
                company.Email,
                company.Address1,
                company.Address2,
                company.Address3,
                company.Phone
            };

            Analyzers.Add(c => c.Name, typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).ToString());
            Analyzers.Add(c => c.Desc, typeof(Lucene.Net.Analysis.StopAnalyzer).ToString());
            Analyzers.Add(c => c.Email, typeof(Lucene.Net.Analysis.StopAnalyzer).ToString());
            Analyzers.Add(c => c.Address1, typeof(Lucene.Net.Analysis.SimpleAnalyzer).ToString());
            Analyzers.Add(c => c.Address2, typeof(Lucene.Net.Analysis.WhitespaceAnalyzer).ToString());
            Analyzers.Add(c => c.Address3, typeof(Lucene.Net.Analysis.KeywordAnalyzer).ToString());
            Analyzers.Add(c => c.Phone, typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).ToString());

            Stores.Add(c => c.Name, FieldStorage.Yes);
            Stores.Add(c => c.Desc, FieldStorage.Yes);

            Indexes.Add(c => c.Email, FieldIndexing.NotAnalyzed);

            TermVectors.Add(c => c.Name, FieldTermVector.WithPositionsAndOffsets);
        }
Пример #10
0
            public SampleIndex2()
            {
                Map = users => from doc in users select new { doc.Name };

                Sort(x => x.Name, SortOptions.String);

                Analyzers.Add(x => x.Name, "Raven.Database.Indexing.Collation.Cultures.SvCollationAnalyzer, Raven.Database");
            }
Пример #11
0
        public Companies_SortByName()
        {
            Map = companies => from company in companies
                  select new { company.Name };

            Sort(c => c.Name, SortOptions.String);

            Analyzers.Add(c => c.Name, typeof(Raven.Database.Indexing.Collation.Cultures.PlCollationAnalyzer).ToString());
        }
Пример #12
0
        public void AddAnalyser(string id, string tokenizer, string filter)
        {
            CustomAnalyzer custom  = new CustomAnalyzer();
            var            filters = filter.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            custom.Filter    = filters;
            custom.Tokenizer = tokenizer;
            Analyzers.Add(id, custom);
        }
Пример #13
0
        public Records_ByData()
        {
            Map = records => from record in records
                  select new { record.DataSourceId, record.Data };

            Indexes.Add(x => x.Data, FieldIndexing.Analyzed);

            Analyzers.Add(x => x.Data, typeof(SimpleAnalyzer).AssemblyQualifiedName);
        }
Пример #14
0
            public Users_ByName()
            {
                Map = users => from u in users
                      select new
                {
                    u.Name
                };

                Analyzers.Add(x => x.Name, "NotExistingAnalyzer");
            }
Пример #15
0
 public ImageByName()
 {
     Map = docs => from i in docs
           select new
     {
         Id   = i.Id,
         Name = new[] { i.Name },
     };
     Index(r => r.Name, FieldIndexing.Search);
     Analyzers.Add(n => n.Name, nameof(NGramAnalyzer));
 }
Пример #16
0
 public ImageByName()
 {
     Map = docs => from i in docs
           select new
     {
         Id   = i.Id,
         Name = new[] { i.Name },
     };
     Index(r => r.Name, FieldIndexing.Analyzed);
     Analyzers.Add(n => n.Name, typeof(NGramAnalyzer).AssemblyQualifiedName);
 }
Пример #17
0
        public Articles_ByArticleBody()
        {
            Map = docs => from doc in docs
                  select new
            {
                doc.ArticleBody
            };

            Stores.Add(x => x.ArticleBody, FieldStorage.Yes);
            Analyzers.Add(x => x.ArticleBody, "StandardAnalyzer");
        }
Пример #18
0
            public MyIndex(string analyzerName)
            {
                Map = customers => from customer in customers
                      select new
                {
                    Name = customer.Name
                };

                Indexes.Add(x => x.Name, FieldIndexing.Search);
                Analyzers.Add(x => x.Name, analyzerName);
            }
Пример #19
0
        public Index_With_NGram_Analyzer()
        {
            Map = companies => from c in companies
                  select new
            {
                Name = c.Name
            };

            Index(r => r.Name, FieldIndexing.Search);
            Analyzers.Add(n => n.Name, nameof(NGramAnalyzer));
        }
Пример #20
0
            public MyDocIndex()
            {
                Map = docs => docs.Select(
                    lm => new MyDocResult()
                {
                    Message  = lm.Message,
                    IsChange = (lm.Type & LogTypeEnum.Changes) == LogTypeEnum.Changes
                });

                Analyzers.Add(lm => lm.Message, "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net");
            }
Пример #21
0
            public void FillDictData(string[] namesArr, FieldStorage[] storesArr, string[] analArr, SuggestionOptions[] sugArr)
            {
                for (int i = 0; i < namesArr.Length; i++)
                {
                    Fields.Add(namesArr[i]);

                    Stores.Add(namesArr[i], storesArr[i]);
                    Analyzers.Add(namesArr[i], analArr[i]);
                    Suggestions.Add(namesArr[i], sugArr[i]);
                }
            }
Пример #22
0
        public CategoryDescription()
        {
            Map = categories => from category in categories
                  select new
            {
                category.Description
            };

            Stores.Add(x => x.Description, FieldStorage.Yes);
            Analyzers.Add(x => x.Description, "Lucene.Net.Analysis.Standard.StandardAnalyzer");
        }
Пример #23
0
        public Users_ByName()
        {
            Map = users => from u in users select new { Name = u.Name, LastName = u.LastName.Boost(10) };

            Indexes.Add(x => x.Name, FieldIndexing.Analyzed);

            IndexSuggestions.Add(x => x.Name, new SuggestionOptions());

            Analyzers.Add(x => x.Name, typeof(SimpleAnalyzer).FullName);

            Stores.Add(x => x.Name, FieldStorage.Yes);
        }
Пример #24
0
        public DeCollationIndex()
        {
            Map = contacts =>
                  from contact in contacts
                  select new
            {
                contact.FirstName,
            };

            Analyzers.Add(x => x.FirstName, typeof(DeCollationAnalyzer).AssemblyQualifiedName);
            Sort(x => x.FirstName, SortOptions.String);
        }
Пример #25
0
        public Posts_ByPostCategory()
        {
            Map = docs => from doc in docs
                  select new
            {
                doc.Body,
                doc.Category
            };

            Stores.Add(x => x.Body, FieldStorage.Yes);
            Analyzers.Add(x => x.Body, typeof(StandardAnalyzer).FullName);
        }
Пример #26
0
        public Users_ByName()
        {
            Map = users => from u in users select new { Name = u.Name, LastName = u.LastName.Boost(10) };

            Indexes.Add(x => x.Name, FieldIndexing.Search);

            IndexSuggestions.Add(x => x.Name);

            Analyzers.Add(x => x.Name, typeof(Lucene.Net.Analysis.SimpleAnalyzer).FullName);

            Stores.Add(x => x.Name, FieldStorage.Yes);
        }
        public UserIndex()
        {
            Map = users => from user in users
                  select new
            {
                user.Name,
                user.Total,
                user.Role
            };

            Indexes.Add(x => x.Name, FieldIndexing.Analyzed);
            Analyzers.Add(x => x.Name, typeof(TurkishAnalyzer.TurkishAnalyzer).AssemblyQualifiedName);
        }
Пример #28
0
            public Audio_Index()
            {
                // audio properties
                Map = audios => from audio in audios
                      select new
                {
                    Id      = audio.Id,
                    AudioId = audio.Id,
                    Name    = audio.Name
                };

                Analyzers.Add(x => x.Name, "SimpleAnalyzer");
            }
Пример #29
0
            public Students_WithFriends()
            {
                Map = students => from student in students
                      let friends = LoadDocument <Student>(student.Friends)
                                    select new Mapping
                {
                    EmailDomain = student.Email.Split('@', StringSplitOptions.None).Last(),
                    Friends     = friends.Select(a => a.Email)
                };

                Analyzers.Add(x => x.Friends, "Lucene.Net.Analysis.SimpleAnalyzer, Lucene.Net");
                Indexes.Add(x => x.Friends, FieldIndexing.Search);
            }
Пример #30
0
            public ZC_CountryCityStateCodeACIndex()
            {
                Map = sEnum => sEnum
                      .Select(t => new { t.CountryCode, CityOrder = t.City, t.City, t.StateCode });

                Reduce = results => results
                         .GroupBy(r => new { r.City, r.CountryCode, r.StateCode })
                         .Select(g => new { g.Key.City, CityOrder = g.Key.City, g.Key.CountryCode, g.Key.StateCode });

                //Bug Collation - following resolves in empty results
                //Without it, {ä ö ü} are analyzed wrongly and are placed at the end of the alphabet
                Analyzers.Add(x => x.CityOrder, typeof(DeCollationAnalyzer).AssemblyQualifiedName);
            }