public IHttpActionResult Search(string q, int page = 1, int pageSize = 10) { ISearchService <Post> service = new ElasticSearchService(); var results = service.Search(q, page, pageSize); return(Ok(results)); }
public QueryExtensionsTests(ServiceLocatorFixture fixture) { _fixture = fixture; _serviceStub = new ElasticSearchService( fixture.ServiceLocationMock.SettingsMock.Object, fixture.ServiceLocationMock.HttpClientMock.Object); }
public static IElasticSearchService <T> Filter <T>(this IElasticSearchService <T> service, Expression <Func <T, CategoryList> > fieldSelector, string filterValue) { Tuple <string, MappingType> fieldInfo = ElasticSearchService <T> .GetFieldInfo(fieldSelector); return(service.Filter(fieldInfo.Item1, filterValue, false)); }
public AnalyzerPipeline( DumpRepository dumpRepo, BundleRepository bundleRepo, PathHelper pathHelper, IOptions <SuperDumpSettings> settings, ElasticSearchService elasticSearch, SimilarityService similarityService, FaultReportingService faultReportingService, IOneAgentSdk dynatraceSdk) { var analyzers = new List <AnalyzerJob>(); analyzers.Add(new DumpAnalyzerJob(dumpRepo, settings, pathHelper, dynatraceSdk)); analyzers.Add(new EmptyAnalyzerJob(dumpRepo)); var postAnalyzers = new List <PostAnalysisJob>(); postAnalyzers.Add(new ElasticSearchJob(bundleRepo, dumpRepo, elasticSearch)); postAnalyzers.Add(new SimilarityAnalyzerJob(similarityService, settings)); postAnalyzers.Add(new FaultReportJob(faultReportingService, settings)); Analyzers = analyzers; InitialAnalyzers = analyzers.Where(analyzerJob => analyzerJob is InitalAnalyzerJob).Cast <InitalAnalyzerJob>(); PostAnalysisJobs = postAnalyzers; }
/// <summary> /// Adds suggestions for supplied properties of {T}, except those hidden by convention of configuration /// </summary> public Indexing EnableSuggestions <TProperty>(params Expression <Func <T, TProperty> >[] fieldSelectors) { if (fieldSelectors == null || fieldSelectors.Length == 0) { return(_instance); } foreach (var fieldSelector in fieldSelectors) { string fieldName = ElasticSearchService <T> .GetFieldInfo(fieldSelector).Item1; // Update existing registration of type? if (Indexing.Suggestions.Any(s => s.Type == typeof(T))) { Indexing.Suggestions.Single(s => s.Type == typeof(T)).InputFields.Add(fieldName); } else { Suggestion suggestion = new Suggestion(typeof(T)); suggestion.InputFields.Add(fieldName); Indexing.Suggestions.Add(suggestion); } } return(_instance); }
public ElasticSearchServiceTests(ServiceLocatorFixture fixture) { _service = new ElasticSearchService <ComplexType>( fixture.ServiceLocationMock.ServerInfoMock.Object, fixture.ServiceLocationMock.SettingsMock.Object, fixture.ServiceLocationMock.HttpClientMock.Object); }
public HomeController( SuperDumpRepository superDumpRepo, BundleRepository bundleRepo, DumpRepository dumpRepo, IDumpStorage dumpStorage, IOptions <SuperDumpSettings> settings, PathHelper pathHelper, RelationshipRepository relationshipRepo, SimilarityService similarityService, ElasticSearchService elasticService, ILoggerFactory loggerFactory, IAuthorizationHelper authorizationHelper, JiraIssueRepository jiraIssueRepository, SearchService searchService, DownloadService downloadService) { this.superDumpRepo = superDumpRepo; this.bundleRepo = bundleRepo; this.dumpRepo = dumpRepo; this.dumpStorage = dumpStorage; this.settings = settings.Value; this.pathHelper = pathHelper; this.relationshipRepo = relationshipRepo; this.similarityService = similarityService; logger = loggerFactory.CreateLogger <HomeController>(); this.authorizationHelper = authorizationHelper; this.jiraIssueRepository = jiraIssueRepository; this.searchService = searchService; this.downloadService = downloadService; }
public ElasticSearchServiceTest() { var bootstrap = new Bootstrap(); IElasticSearchConfigure elasticSearchConfigure = Moq.Mock.Of <IElasticSearchConfigure>(); Moq.Mock.Get(elasticSearchConfigure).Setup(x => x.Nodes).Returns("http://localhost:9200"); elasticSearchService = new ElasticSearchService(elasticSearchConfigure); }
static void Main(string[] args) { List <LogDto> users = new List <LogDto>(); users.Add(new LogDto() { Name = "Kaley", Surname = "Willms", MobilNo = "1-666-117-6420", BirthDate = "10/7/1996", LastLocation = "47.0266, -123.4382", DateTime = DateTime.Now, Suggest = new CompletionField() { Input = new[] { "Kaley", "10", "47" } } }); users.Add(new LogDto() { Name = "Beahan", Surname = "Tod", MobilNo = "1-666-117-6420", BirthDate = "10/7/1996", LastLocation = "47.0266, -123.4382", DateTime = DateTime.Now, Suggest = new CompletionField() { Input = new[] { "Beahan", "10", "47" } } }); users.Add(new LogDto() { Name = "deneme", Surname = "test", MobilNo = "1-666-117-6420", BirthDate = "10/7/1996", LastLocation = "47.0266, -123.4382", DateTime = DateTime.Now, Suggest = new CompletionField() { Input = new[] { "deneme", "10", "47" } } }); var connectionSettings = new ConnectionSettings(new Uri("http://localhost:9200")); IElasticSearchService autocompleteService = new ElasticSearchService(connectionSettings); string userSuggestIndex = "user_suggest"; bool isCreated = autocompleteService.CreateIndexAsync(userSuggestIndex).Result; if (isCreated) { autocompleteService.IndexAsync(userSuggestIndex, users).Wait(); } }
public ActionResult Search(ElasticSearchQuery searchQuery) { // ElasticSearchService elasticService = new ElasticSearchService(); var result = elasticService .Search(User.Identity.Name, searchQuery.RawSearch, 1, 20); return(PartialView("_SearchResult", result)); }
public async Task OneEventWithMapping() { if (_disableElasticSearch) { return; } const string INDEX_NAME = "mapped-transfer-logs"; var elasticClient = CreateLocalElasticClient(); //surround with "using" so that anything in a buffer is sent on dispose using (var elasticSearchService = new ElasticSearchService(elasticClient)) { try { //setup await elasticSearchService.CreateIfNotExists(INDEX_NAME); var indexer = elasticSearchService.CreateIndexerForEventLog <TransferEvent_ERC20, CustomTransferSearchDocumentDto>( INDEX_NAME, (from) => new CustomTransferSearchDocumentDto { From = from.Event.From, To = from.Event.To, Value = from.Event.Value.ToString(), BlockNumber = from.Log.BlockNumber.Value.ToString(), TxHash = from.Log.TransactionHash, LogAddress = from.Log.Address, LogIndex = (int)from.Log.LogIndex.Value, DocumentKey = $"{from.Log.TransactionHash}_{from.Log.LogIndex.Value}" }, documentsPerBatch: 1); var web3 = new Web3.Web3(BlockchainUrl); var blockchainProcessor = web3.Processing.Logs.CreateProcessor <TransferEvent_ERC20>((transfer) => indexer.IndexAsync(transfer)); var cancellationTokenSource = new CancellationTokenSource(); //execute await blockchainProcessor.ExecuteAsync(3146694, cancellationTokenSource.Token, 3146684); //assert await Task.Delay(1000); // allow time to index Assert.Equal(19, await elasticSearchService.CountDocumentsAsync(INDEX_NAME)); //http://localhost:9200/transfer-logs/_search?q=from:0x1b31d19b6a9a942bbf3c197ca1e5efede3ff8ff2 } finally { await elasticSearchService.DeleteIndexAsync(INDEX_NAME); } } }
public void BasicTest() { var config = new AppConfigService(log); var elastic = new ElasticSearchService(config, log); IHomeEventsService target = new HomeEventsService(config, elastic, log); var result = target.GetEventsWindow(new DateTime(2018, 02, 03, 17, 04, 00)); Assert.AreEqual(29, result.Count()); Assert.IsNotNull(result.First().Id); }
public TestService( ILogger <TestService> logger, IDbService dbService, IJwtService jwtService, RedisService redisService, ElasticSearchService es) { this._logger = logger; base._dbService = dbService; this._jwtService = jwtService; this._redis = redisService; this._es = es; }
/// <summary> /// Register a property as searchable. /// <para> /// Use this if you can't alter the source code of the object to index, /// thus preventing you from using [Searchable] /// </para> /// </summary> public static Indexing IncludeProperty <T, TProperty>(this CustomPropertyConvention <T> instance, Expression <Func <T, TProperty> > fieldSelector) where T : IContent { string fieldName = ElasticSearchService <T> .GetFieldInfo(fieldSelector).Item1; Type type = typeof(T); if (!Indexing.Instance.SearchableProperties.ContainsKey(type)) { Indexing.Instance.SearchableProperties.TryAdd(type, new[] { fieldName }); } else { if (Indexing.Instance.SearchableProperties.TryGetValue(type, out string[] current))
/// <summary> /// Apply stemming for field <paramref name="fieldSelector"/> /// </summary> /// <param name="fieldSelector">An expression, typically a property or an instance/extension method.</param> public Indexing StemField <TProperty>(Expression <Func <T, TProperty> > fieldSelector) { var fieldName = ElasticSearchService <T> .GetFieldInfo(fieldSelector).Item1; if (WellKnownProperties.Analyze.Contains(fieldName)) { return(_instance); } Logger.Debug("Adding stemming for field: " + fieldName); WellKnownProperties.Analyze.Add(fieldName); return(_instance); }
public AdminController(SimilarityService similarityService, DumpRepository dumpRepository, BundleRepository bundleRepository, ILoggerFactory loggerFactory, IdenticalDumpRepository identicalDumpRepository, JiraIssueRepository jiraIssueRepository, IOptions <SuperDumpSettings> settings, ElasticSearchService elasticService) { this.similarityService = similarityService; this.bundleRepository = bundleRepository; this.identicalDumpRepository = identicalDumpRepository; this.jiraIssueRepository = jiraIssueRepository; this.elasticService = elasticService; logger = loggerFactory.CreateLogger <AdminController>(); this.settings = settings.Value; }
/// <summary> /// ürün bilgilerini elde edip elastic searche gönderen fonksiyon /// </summary> /// <param name="urlPath">hangi site adresilerinin indexlemede kullanılacağı parametre</param> /// <returns></returns> public static async Task GetUrunlerAndPostElasticSearch(string urlPath) { IHtmlParserHelper _htmlParserManager = new HtmlParserHelper(ConfigurationManager.AppSettings["baseAddress"], urlPath); IElasticSearchService <Urun> _elasticSearchService = new ElasticSearchService <Urun>(ConfigurationManager.AppSettings["aliasName"], ConfigurationManager.AppSettings["indexName"]); var urunler = await _htmlParserManager.GetUrunListesi(); var result = _elasticSearchService.PostToElasticSearch(urunler); if (result.Item1) { Console.WriteLine(string.Format("{0} için Elastic Search indexlemesi başarılı", urlPath)); } else { Console.WriteLine(string.Format("{0} için Elastic Search indexlemesi başarısız. Hata: {1}", urlPath, result.Item2)); } }
public void Setup() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _elasticSettingsMock = new Mock <IOptions <ElasticSearchSettings> >(); _appSettingsMock = new Mock <IOptions <AppSettings> >(); _appSettingsMock.Setup(a => a.Value).Returns(new AppSettings { ElasticBatchSize = 1000 }); _elasticClientMock = new Mock <IElasticClient>(); _elasticSettingsMock.Setup(a => a.Value).Returns(new ElasticSearchSettings { Nodes = "http://localhost:9222", IsLogged = true, DefaultIndex = "costs", DefaultSearchSize = 50 }); _permissionServiceMock = new Mock <IPermissionService>(); _mapperMock = new Mock <IMapper>(); _logger = new Mock <ILogger>(); _costSearchBuilderMock = new Mock <ICostSearchBuilder>(); _costViewDetailsMock = new Mock <ICostViewDetails>(); _elasticSearchService = new ElasticSearchService( new List <Lazy <ICostSearchBuilder, PluginMetadata> > { new Lazy <ICostSearchBuilder, PluginMetadata>(() => _costSearchBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }, _logger.Object, _permissionServiceMock.Object, _efContext, _mapperMock.Object, _elasticClientMock.Object, new List <Lazy <ICostViewDetails, PluginMetadata> > { new Lazy <ICostViewDetails, PluginMetadata>(() => _costViewDetailsMock.Object, new PluginMetadata { BuType = BuType.Pg }) } ); }
/// <summary> /// Enables highlighting on the supplied field(s). /// Fields named MainIntro, MainBody and Description are included by default /// </summary> public Indexing EnableHighlighting <TProperty>(params Expression <Func <T, TProperty> >[] fieldSelectors) { if (fieldSelectors == null || fieldSelectors.Length == 0) { return(_instance); } foreach (var fieldSelector in fieldSelectors) { string fieldName = ElasticSearchService <T> .GetFieldInfo(fieldSelector).Item1; if (!Indexing.Highlights.Contains(fieldName)) { Indexing.Highlights.Add(fieldName); } } return(_instance); }
public async Task OneEvent() { if (_disableElasticSearch) { return; } const string INDEX_NAME = "transfer-logs"; var elasticClient = CreateLocalElasticClient(); //surround with "using" so that anything in a buffer is sent on dispose using (var elasticSearchService = new ElasticSearchService(elasticClient)) { try { //setup await elasticSearchService.CreateIfNotExists(INDEX_NAME); var indexer = elasticSearchService.CreateIndexerForEventLog <TransferEvent_ERC20>(INDEX_NAME, documentsPerBatch: 1); var web3 = new Web3.Web3(BlockchainUrl); var blockchainProcessor = web3.Processing.Logs.CreateProcessor <TransferEvent_ERC20>((transfer) => indexer.IndexAsync(transfer)); var cancellationTokenSource = new CancellationTokenSource(); //execute await blockchainProcessor.ExecuteAsync(3146694, cancellationTokenSource.Token, 3146684); //assert await Task.Delay(1000); // allow time to index Assert.Equal(19, await elasticSearchService.CountDocumentsAsync(INDEX_NAME)); //http://localhost:9200/transfer-logs/_search?q=from:0x1b31d19b6a9a942bbf3c197ca1e5efede3ff8ff2 } finally { await elasticSearchService.DeleteIndexAsync(INDEX_NAME); } } }
private static void LoadDataInSQLServer(string filepath) { var businesses = File.ReadAllLines(filepath); var srv = new ElasticSearchService(); var cnt = businesses.Length; foreach (var line in businesses) { if (line.Length > 150) { continue; } var k = new Business { Name = line.Trim(), Code = Util.TimeStampCode("BIZ") }; _context.Businesses.Add(k); _context.SaveChanges(); cnt--; Console.WriteLine("Remains: " + cnt); srv.IndexBusinessSync(k); } }
/// <summary> /// arama sonuçlarını dönen sayfa /// </summary> /// <param name="inModel">post edilen sayfanın modeli</param> /// <returns></returns> public ActionResult AramaSonuclari(IndexViewModel inModel) { IElasticSearchService <Urun> _elasticSearchService = new ElasticSearchService <Urun>(ConfigurationManager.AppSettings["aliasName"], ConfigurationManager.AppSettings["indexName"]); var outModel = new AramaSonuclariViewModel(); if (!string.IsNullOrEmpty(inModel.Text)) { var textList = inModel.Text.Split(' '); var result = _elasticSearchService.SearchFromElasticSearch(textList, "urunAdi"); if (result.Item1) { outModel.UrunListesi = result.Item2; } else { outModel.HataMesaji = result.Item3; } } return(View(outModel)); }
public SearchService() { //_luceneSearchService = new LuceneSearchService(); _luceneSearchService = new ElasticSearchService(); ElasticSearchService.Initialize(_luceneSearchService); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine(HelpText); return; } var firstArg = args[0]; var builder = new ConfigurationBuilder() .SetBasePath(Environment.CurrentDirectory) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables() .Build(); var awsOptions = builder.GetAWSOptions(); Console.WriteLine(awsOptions.Profile + ":" + awsOptions.ProfilesLocation + ": " + awsOptions.Region.DisplayName); var textractTextService = new TextractTextDetectionService(awsOptions.CreateServiceClient <IAmazonTextract>()); var textractAnalysisService = new TextractTextAnalysisService(awsOptions.CreateServiceClient <IAmazonTextract>()); var translateService = new TranslateService(awsOptions.CreateServiceClient <IAmazonTranslate>()); var comprehendService = new ComprehendService(awsOptions.CreateServiceClient <IAmazonComprehend>()); var comprehendMedicalService = new ComprehendService(awsOptions.CreateServiceClient <IAmazonComprehendMedical>()); var elasticSearchService = new ElasticSearchService(ElasticSearchEndpoint, ElasticSearchDomainName); switch (firstArg) { case "--detect-text-local": new DetectTextHandler(textractTextService).Handle(LocalEmploymentFile); break; case "--detect-text-s3": new DetectTextS3Handler(textractTextService).Handle(BucketName, S3File); break; case "--pdf-text": new PdfTextHandler(textractTextService).Handle(BucketName, PdfFile); break; case "--reading-order": new ReadingOrderHandler(textractTextService).Handle(BucketName, TwoColumnImage); break; case "--translate": new TranslateHandler(textractTextService, translateService).Handle(BucketName, S3File); break; case "--search": new SearchHandler(textractTextService, elasticSearchService).Handle(BucketName, S3File); break; case "--forms": new FormsHandler(textractAnalysisService).Handle(BucketName, FormFile); break; case "--forms-redaction": new FormsRedactionHandler(textractAnalysisService).Handle(BucketName, FormFile, LocalFolder, LocalEmploymentFile); break; case "--tables": new TablesHandler(textractAnalysisService).Handle(BucketName, FormFile); break; case "--tables-expense": new TablesExpenseHandler(textractAnalysisService).Handle(BucketName, ExpenseFile); break; case "--nlp-comprehend": new NlpComprehendHandler(textractTextService, comprehendService).Handle(LocalSimpleFile); break; case "--nlp-medical": new NlpComprehendMedicalHandler(textractTextService, comprehendMedicalService).Handle(LocalMedicalFile); break; default: Console.WriteLine(HelpText); break; } }
public SearchController() { service = new ElasticSearchService(); }
/// <summary> /// Include a custom property when indexing this type. /// The name of the property will be the same as the property/method in the <paramref name="fieldSelector"/> parameter. /// <para> /// If you need more control over the name, and/or the method supplying the data to be indexed has /// no relations to the type, use the overload <c>IncludeField(string, Expression, bool)</c> /// </para> /// </summary> /// <example> /// <para>Extension/instance method: IncludeField(x => x.CustomStuff());</para> /// <para>Property method: IncludeField(x => x.MyCustomProp);</para> /// <para>Custom name: IncludeField("Foobar", x => x.MyCustomProp);</para> /// </example> /// <param name="fieldSelector">An expression, typically a property or an instance/extension method.</param> /// <param name="stem">Should stemming be applied for this property?</param> public Indexing IncludeField <TProperty>(Expression <Func <T, TProperty> > fieldSelector, bool stem = false) { string fieldName = ElasticSearchService <T> .GetFieldInfo(fieldSelector).Item1; return(IncludeField(fieldName, fieldSelector, stem)); }
public ElasticSearchServiceTests() { Factory.SetupServiceLocator(); _service = new ElasticSearchService <ComplexType>(); }
public ElasticSearchJob(BundleRepository bundleRepo, DumpRepository dumpRepo, ElasticSearchService elasticSearch) { this.bundleRepo = bundleRepo; this.dumpRepo = dumpRepo; this.elasticSearch = elasticSearch; }
public ElasticSearchController(ElasticSearchService elasticService, ILoggerFactory loggerFactory) { this.elasticService = elasticService; logger = loggerFactory.CreateLogger <ElasticSearchController>(); }
public ElasticSearchController(ElasticSearchService elasticService) { this.elasticService = elasticService; }