public IList <EmployeeModel> SolrSearchData(ISolrOperations <SearchResultItem> solr, string searchValue) { IList <EmployeeModel> resultList = new List <EmployeeModel>(); SolrQueryResults <SearchResultItem> searchItems; if (searchValue == null) { searchItems = solr.Query(SolrQuery.All); } else { var solrQueuries = new List <SolrQuery>(); solrQueuries.Add(new SolrQuery("firstname_t:" + searchValue + "*")); solrQueuries.Add(new SolrQuery("lastname_t:" + searchValue + "*")); solrQueuries.Add(new SolrQuery("address_t:" + searchValue + "*")); solrQueuries.Add(new SolrQuery("salary_t:" + searchValue + "*")); solrQueuries.Add(new SolrQuery("department_t:" + searchValue + "*")); SolrMultipleCriteriaQuery solrQuery = new SolrMultipleCriteriaQuery(solrQueuries.ToArray(), "OR"); searchItems = solr.Query(solrQuery); } foreach (SearchResultItem item in searchItems) { resultList.Add(new EmployeeModel { Id = item.Id, FirstName = item.FirstName, LastName = item.LastName, Address = item.Address, Salary = item.Salary, Department = item.Department }); } return(resultList); }
public IActionResult Index() { ISolrOperations <Employee> solr = ServiceLocator.Current.GetInstance <ISolrOperations <Employee> >(); SolrQueryResults <Employee> results = solr.Query(new SolrQueryByField("name", "solr")); var solr1 = ServiceLocator.Current.GetInstance <ISolrOperations <Dictionary <string, object> > >(); solr1.Add(new Dictionary <string, object> { { "id", "id1234" }, { "manu", "Asus" }, { "popularity", 6 } }); solr1.Commit(); return(View()); //string json = JsonConvert.SerializeObject(solr1); //return this.Content(json); // solr.Add (results); // }
protected override SolrNetListener <Entity> GetSolrNetListener(ISolrOperations <Entity> solr) { return(new SolrNetListener <Entity>(solr) { AddParameters = addParameters }); }
public void DeleteFromPublishedIndex(object id) { ISolrOperations <CmsSearchResultItemPublished> instancePublished = ServiceLocator.Current.GetInstance <ISolrOperations <CmsSearchResultItemPublished> >(); instancePublished.Delete(id.ToString()); instancePublished.Commit(); }
public void AutoTrackRepos(GitHubUser user) { ISolrOperations <CodeDoc> solr = ServiceLocator.Current.GetInstance <ISolrOperations <CodeDoc> >(); var repos = user.GitHubClient.Repository.GetAllPublic().Result; foreach (var repo in repos) { var commits = user.GitHubClient.Repository.Commit.GetAll(repo.Owner.Login, repo.Name).Result; foreach (var commit in commits) { if (commit.Author != null && commit.Author.Login != user.GitHubClient.User.Current().Result.Login) { continue; } var docsToAdd = GetDocumentsFromCommit(user, repo, commit); foreach (var doc in docsToAdd) { solr.Add(doc); } } Console.WriteLine("Finished tracking repository {0} for {1} to Solr", repo.Name, user.UUID); solr.Commit(); } }
/// <summary> /// 真正的检索方法,需要派生类进行实现 /// </summary> /// <param name="condition">查询条件</param> /// <param name="solr">Solr检索器对象</param> /// <returns>检索结果</returns> protected virtual Result GetSearchResult(SearchCondition condition, ISolrOperations <Record> solr) { QueryOptions queryOptions = BuildQueryOptions(condition); List <KeyValuePair <string, string> > keyValuePairList = new List <KeyValuePair <string, string> >(); if (condition.KeyWord != "*:*") { keyValuePairList.Add(new KeyValuePair <string, string>("defType", "extlucene")); } //queryOptions.ExtraParams = keyValuePairList.ToArray(); //fixbug if (queryOptions.ExtraParams == null || queryOptions.ExtraParams.Count() > 0) { List <KeyValuePair <string, string> > oldExtraParams = new List <KeyValuePair <string, string> >(queryOptions.ExtraParams); //配置以派生类为准 keyValuePairList.RemoveAll(v => oldExtraParams.Any(f => f.Key == v.Key)); keyValuePairList.AddRange(oldExtraParams); } queryOptions.ExtraParams = keyValuePairList.ToArray(); ISolrQuery query = new SolrQuery(condition.KeyWord); SolrQueryResults <Record> result = solr.Query(query, queryOptions); return(TransformSolrQueryResult(result, condition)); }
public SolrInitializer(OutputContext context, ISolrCoreAdmin admin, ISolrOperations <Dictionary <string, object> > solr, ITemplateEngine engine) { _context = context; _admin = admin; _solr = solr; _engine = engine; }
public void DeleteMediaFromIndex(string mediaId) { ISolrOperations <CmsSearchResultItem> instance = ServiceLocator.Current.GetInstance <ISolrOperations <CmsSearchResultItem> >(); instance.Delete(mediaId.StartsWith("media") ? mediaId.ToString((IFormatProvider)CultureInfo.InvariantCulture) : "media" + mediaId.ToString((IFormatProvider)CultureInfo.InvariantCulture)); instance.Commit(); }
public ManufacturerController(ISolrReadOnlyOperations<Manufacturer> solr, ISolrOperations<Manufacturer> writer) { this.solr = solr; this.writer = writer; this.names = new List<string> { "samsung", "microsoft", "dell", "logitech", "hp", "panasonic", "sony", "assus", "gigabyte", "amt", "nvidia", "toshiba", "lexmark" }; }
public QueryResponse DoSearch(CourseQuery query) { //create response QueryResponse queryResponse = new QueryResponse(); //save query queryResponse.OriginalQuery = query; //get solr ISolrOperations <Course> solr = _connection.GetSolrInstance(); //query QueryOptions options = new QueryOptions() { Rows = query.Rows, StartOrCursor = new StartOrCursor.Start(query.Start), Highlight = Highlights.BuildParameters() }; //execute the query ISolrQuery solrQuery = new SolrQuery(query.Query); SolrQueryResults <Course> solrResult = solr.Query(solrQuery, options); //Set response ResponseExtraction responseExtractions = new ResponseExtraction(); responseExtractions.SetHeader(queryResponse, solrResult); responseExtractions.SetBody(queryResponse, solrResult); return(queryResponse); }
// TODO: too many injection public SolrService(ISolrOperations <Building> buildings, ISolrOperations <Lock> locks, ISolrOperations <Group> groups, ISolrOperations <Medium> medium) { _buildings = buildings; _locks = locks; _groups = groups; _medium = medium; }
/// <summary> /// Return the top <see cref="RESULTS" /> results for a given natural language query in a channel. /// </summary> public List <CodeDoc> NaturalLangQuery(string search, string channelId) { ISolrOperations <CodeDoc> solr = ServiceLocator.Current.GetInstance <ISolrOperations <CodeDoc> >(); var opts = new QueryOptions(); var lang = GetLanguageRequest(search); if (!string.IsNullOrEmpty(lang)) { opts.AddFilterQueries(new SolrQueryByField("prog_language", lang)); } opts.AddFilterQueries(new SolrQueryByField("channel", channelId)); opts.Rows = RESULTS; var query = new LocalParams { { "type", "boost" }, { "b", "recip(ms(NOW,author_date),3.16e-11,-1,1)" } } +(new SolrQuery("patch:\"" + search + "\"") || new SolrQuery("commit_message:\"" + search + "\"")); var codeQuery = solr.Query(query, opts); List <CodeDoc> results = new List <CodeDoc>(); foreach (CodeDoc doc in codeQuery) { results.Add(doc); } return(results); }
private static void DeleteIndex <T>(ISolrOperations <T> solr) { Console.WriteLine("Clearing Index"); var solrQueryResults = solr.Query(new SolrQuery("*")); solr.Delete(solrQueryResults); solr.Commit(); }
/// <summary> /// removes a given user's repo from a channel /// </summary> /// <param name="user"></param> /// <param name="channel"></param> /// <param name="repository"></param> public void UntrackRepository(GitHubUser user, String repository) { ISolrOperations <CodeDoc> solr = ServiceLocator.Current.GetInstance <ISolrOperations <CodeDoc> >(); solr.Delete(new SolrQuery("channel:" + user.ChannelID) && new SolrQuery("repo:" + repository) && new SolrQuery("committer_name:" + user.UserID)); solr.Commit(); }
public void FixtureSetup() { var nhConfig = ConfigurationExtensions.GetNhConfig(); mockSolr = MockRepository.GenerateMock<ISolrOperations<Entity>>(); nhConfig.SetListener(new SolrNetListener<Entity>(mockSolr)); new SchemaExport(nhConfig).Execute(false, true, false); sessionFactory = nhConfig.BuildSessionFactory(); }
public MoviesService(ILogger <MoviesService> logger, ISolrOperations <Movie> solr, string appBasePath) { _solr = solr; _appBasePath = appBasePath; _logger = logger; Initialize(); }
public SolrService( ISolrOperations <SongSearch> songSearchOperations, IGetSongsFromSearchResultsQuery getSongsFromSearchResultsQuery ) { _songSearchOperations = songSearchOperations; _getSongsFromSearchResultsQuery = getSongsFromSearchResultsQuery; }
public FeedService(IDbContextFactory <FeedReaderDbContext> dbFactory, ISolrOperations <Solrs.FeedItem> solrFeedItems, IDistributedCache remoteCache, IMemoryCache memCache, ILogger <FeedService> logger) { _dbFactory = dbFactory; _remoteCache = remoteCache; _memCache = memCache; _logger = logger; _solrFeedItems = solrFeedItems; }
public SolrNetListener(ISolrOperations <T> solr) { if (solr == null) { throw new ArgumentNullException("solr"); } this.solr = solr; }
public HomeController(ISolrReadOnlyOperations<Product> solr, ISolrOperations<Product> writer) { this.solr = solr; this.writer = writer; this.categories = new List<string> { "myszki", "klawiatury", "mnitory", "rtv", "agd", "cpu", "dyski" }; this.manufactures = new List<string> { "seagate", "samsung", "dell", "hp", "apple", "microsoft", "logitech" }; }
/// <summary> /// 真正的检索方法,需要派生类进行实现 /// </summary> /// <param name="condition">查询条件</param> /// <param name="solr">Solr检索器对象</param> /// <returns>检索结果</returns> protected virtual Result GetSearchResult(SearchCondition condition, ISolrOperations <Record> solr) { QueryOptions queryOptions = BuildQueryOptions(condition); ISolrQuery query = new SolrQuery(condition.KeyWord); ISolrQueryResults <Record> result = solr.Query(query, queryOptions); return(TransformSolrQueryResult(result, condition)); }
protected TrackDao( ISolrOperations <TrackDTO> solrForTracksCore, ISolrOperations <SubFingerprintDTO> solrForSubfingerprintsCore, ISolrQueryBuilder solrQueryBuilder) { this.solrForTracksCore = solrForTracksCore; this.solrForSubfingerprintsCore = solrForSubfingerprintsCore; this.solrQueryBuilder = solrQueryBuilder; }
public static ISolrOperations <T> GetSolrOperations(string solrUrl) { if (solrOperations == null) { Startup.Init <T>(solrUrl); solrOperations = ServiceLocator.Current.GetInstance <ISolrOperations <T> >(); } return(solrOperations); }
public ParallelSolrWriter(OutputContext context, ISolrOperations <Dictionary <string, object> > solr) { _context = context; _solr = solr; _fields = context.OutputFields.Where(f => f.Type != "byte[]").ToArray(); _options = new ParallelOptions() { MaxDegreeOfParallelism = context.Connection.MaxDegreeOfParallelism }; }
internal SubFingerprintDao(ISolrOperations <SubFingerprintDTO> solr, IDictionaryToHashConverter dictionaryToHashConverter, IHashConverter hashConverter, ISolrQueryBuilder solrQueryBuilder) { this.solr = solr; this.dictionaryToHashConverter = dictionaryToHashConverter; this.hashConverter = hashConverter; this.solrQueryBuilder = solrQueryBuilder; var hashinConfig = new DefaultHashingConfig(); fingerprintLength = hashinConfig.NumberOfLSHTables * hashinConfig.NumberOfMinHashesPerTable; }
public SolrSearchService( IPostRepository posts, ISolrOperations<Post> postOp, ISolrConnection connection, IConfigurationService service) { this.posts = posts; this.postOp = postOp; this.connection = connection; this.service = service; }
public BadgeController(IWebHostEnvironment hostEnvironment, IOptions <MongoDbSetting> mongoDbOptions, Repository <DataAccess.Badge> badge, ISolrOperations <SolrBadgeModel> solr) { _badge = badge; _solr = solr; _mongoDbOptions = mongoDbOptions.Value; _hostEnvironment = hostEnvironment; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.badgeCollection = db.GetCollection <DigiBadges.Models.Badge>("Badges"); }
public SolrSearchService( IPostRepository posts, ISolrOperations <Post> postOp, ISolrConnection connection, IConfigurationService service) { this.posts = posts; this.postOp = postOp; this.connection = connection; this.service = service; }
public void FixtureSetup() { var nhConfig = ConfigurationExtensions.GetNhConfig(); mockSolr = MockRepository.GenerateMock<ISolrOperations<Entity>>(); var provider = MockRepository.GenerateMock<IServiceProvider>(); var mapper = MockRepository.GenerateMock<IReadOnlyMappingManager>(); provider.Expect(x => x.GetService(typeof (IReadOnlyMappingManager))).Return(mapper); NHHelper.SetListener(nhConfig, GetSolrNetListener(mockSolr)); new SchemaExport(nhConfig).Execute(false, true, false); sessionFactory = nhConfig.BuildSessionFactory(); }
public SolrMachine(string coreName) { var url = string.Format("http://xxx/solr/{0}", coreName); myContainer.Register(Component.For <IHttpWebRequestFactory>().ImplementedBy <SolrAuth>()); var solrFacility = new SolrNetFacility(string.Format("http://xxx/solr/{0}", "defaultCollection")); solrFacility.AddCore(coreName, typeof(T), url); myContainer.AddFacility(solrFacility); this.actuallyInstance = myContainer.Resolve <ISolrOperations <T> >(); }
private static void AddEmailToIndex(ISolrOperations <EmailIndex> solr, DateTime dateSent, string to, string from, string subject, string messageBody) { solr.Add(new EmailIndex { DateSent = dateSent, To = to, From = from, Subject = subject, MessageBody = messageBody }); }
/// <summary> /// 真正的检索方法,需要派生类进行实现 /// </summary> /// <param name="condition">查询条件</param> /// <returns>检索结果</returns> protected override Result GetSearchResult(SearchCondition condition) { ISolrOperations <Record> solr = null; try { solr = ServiceLocator.Current.GetInstance <ISolrOperations <Record> >(); } catch { throw new ConfigurationErrorsException(SolrCoreName + ",没有进行初始化"); } return(GetSearchResult(condition, solr)); }
public UsersController(IOptions <MongoDbSetting> mongoDbOptions, IEmailSender emailSender, ISolrOperations <SolrUsersModel> solr) { _mongoDbOptions = mongoDbOptions.Value; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.usersCollection = db.GetCollection <Users>("Users"); this.userRoleCollection = db.GetCollection <UserRoles>("UserRoles"); this.issuersCollection = db.GetCollection <Issuers>("Issuers"); _emailSender = emailSender; _solr = solr; }
public SolrSearch(string indexName) { IndexName = indexName; if (!_initialized) { Startup.Init <SearchResult>(string.Format("http://solr.<domain>:8080/solr/{0}/", IndexName)); _initialized = true; } _solr = ServiceLocator.Current.GetInstance <ISolrOperations <SearchResult> >(); }
// Methods public SOLRHistoryEngineHook(Database database) { Assert.ArgumentNotNull(database, "database"); this.m_database = database; if (ServiceLocator.Current.IsNotNull()) { Startup.Init <SOLRItem>(Config.SolrServiceLocation); solr = ServiceLocator.Current.GetInstance <ISolrOperations <SOLRItem> >(); IndexingManager.Provider.OnRemoveItem += new EventHandler(Provider_OnRemoveItem); IndexingManager.Provider.OnUpdateItem += new EventHandler(Provider_OnUpdateItem); } }
// Methods public SOLRHistoryEngineHook(Database database) { Assert.ArgumentNotNull(database, "database"); this.m_database = database; if (ServiceLocator.Current.IsNotNull()) { Startup.Init<SOLRItem>(Config.SOLRServiceLocation); solr = ServiceLocator.Current.GetInstance<ISolrOperations<SOLRItem>>(); IndexingManager.Provider.OnRemoveItem += new EventHandler(Provider_OnRemoveItem); IndexingManager.Provider.OnUpdateItem += new EventHandler(Provider_OnUpdateItem); } }
static void Main(string[] args) { Startup.Init<BaseballGame>(Global.SOLR_LOCATION); _solrOperations = ServiceLocator.Current.GetInstance<ISolrOperations<BaseballGame>>(); if (SHOULD_LOAD_GAMES) LoadGamesIntoIndex(); else Console.WriteLine("You have indexing set to OFF - just a friendly reminder"); RunExamples(); Console.WriteLine("Press any key to quit"); Console.ReadKey(); }
public QueryExamples(ISolrOperations<BaseballGame> solrOperationsOperations) { _solrOperations = solrOperationsOperations; }
public HomeController() { _solrOperator = ServiceLocator.Current.GetInstance<ISolrOperations<BaseballGame>>(); _queryBuilder = new BaseballQueryBuilder {SortDirection = "A", CurrentSortTerm = "bg_homeTeam"}; }
public BaseballQueryBuilder() { _solrOperations = ServiceLocator.Current.GetInstance<ISolrOperations<BaseballGame>>(); this.AppliedFacets = new List<Tuple<string, string>>(); }
public QuoteController() { _solr = ServiceLocator.Current.GetInstance<ISolrOperations<Quote>>(); }
public void FixtureSetup() { solr_searchable = ServiceLocator.Current.GetInstance<ISolrOperations<Searchable>>(); }
public HitterController() { _solr = ServiceLocator.Current.GetInstance<ISolrOperations<Hitter>>(); }
private static void PopulatePivotalProject(MapperFactory mapperFactory, ISolrOperations<RequirementsDocument> solr) { Configuration.Project pivotproject = new Configuration.Project() { ProjectName = "Program Mgmt", SystemType = SystemType.Pivotal,Url = @"https://www.pivotaltracker.com/services/v3/" }; var mapper = mapperFactory.GetMapperForProject(pivotproject); RequirementsDocument[] docs = mapper.FindAllWorkItemsForProject(); //submit them to solr solr.AddRange(docs, new AddParameters { CommitWithin = 10000 }); }
private void UpdateSolrIndexForProject(IndexSettings settings, ISolrOperations<CodeDocument> solr, Project proj) { List<string> alldocs = null; //find out if directory exists before doing anything to the index if (!Directory.Exists(proj.Path)) { Console.WriteLine(DateTime.Now.ToString() + ": Directory for project " + proj.ProjectName + " did not exist, skipping"); return; } //find all of the files using (var csw = new ConsoleStopWatch("")) { alldocs = GetDocsForProject(proj, settings.DefaultIncludedPath, settings.DefaultExcludedPath); csw.Name = "Finding " + alldocs.Count.ToString() + " files for project " + proj.ProjectName; } using (var csw = new ConsoleStopWatch("Deleting all solr docs for project " + proj.ProjectName)) { solr.Delete(new SolrQuery("project:\"" + proj.ProjectName + "\"")); solr.Commit(); } //breakout the file list into chunks of DOCS_PER_POST for speed. One at a time is too slow, too many can cause solr memory and thread issues var fileChunks = Chunkify(alldocs.ToArray(), DOCS_PER_POST); using (var csw = new ConsoleStopWatch("Adding the documents to solr for project " + proj.ProjectName)) { //convert each to a solr document for (int i = 0; i < fileChunks.Length; i++) { var file = fileChunks[i]; var codedocs = MakeDocument(file, proj); //submit each to solr //Tweak to leverage new CommitIWithin option of SolrNet so that we do not need to pay the cost of a commit for each group. solr.AddRange(codedocs, new AddParameters { CommitWithin = 10000 }); } solr.Optimize(); } }
protected TrackDao(ISolrOperations<TrackDTO> solrForTracksCore, ISolrOperations<SubFingerprintDTO> solrForSubfingerprintsCore) { this.solrForTracksCore = solrForTracksCore; this.solrForSubfingerprintsCore = solrForSubfingerprintsCore; }
/// <summary> /// Get teh current instance of the SOLR /// </summary> /// <param name="item">Get the item state</param> public SpellCheck(Item item) { solr = ServiceLocator.Current.GetInstance<ISolrOperations<SearchResultItem>>(); var indexable = new SitecoreIndexableItem(item); indexName = GetContextIndexName(indexable); }
protected override SolrNetListener<Entity> GetSolrNetListener(ISolrOperations<Entity> solr) { return new SolrNetListener<Entity>(solr) {AddParameters = addParameters}; }
public SolrTest() { _solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>(); SolrContext.SetConfig("http://192.168.157.130:8080/solr", "test", "json"); }
public BaseballQueryBuilder(ISolrOperations<BaseballGame> solrOperations) { _solrOperations = solrOperations; this.AppliedFacets = new List<Tuple<string, string>>(); }
protected virtual SolrNetListener<Entity> GetSolrNetListener(ISolrOperations<Entity> solr) { return new SolrNetListener<Entity>(solr); }
public SolrController(ISolrOperations<Product> solr) { this.solr = solr; }
protected HashBinDao(ISolrOperations<SubFingerprintDTO> solr) { this.solr = solr; }
public SearchController() { solr = ServiceLocator.Current.GetInstance<ISolrOperations<Dictionary<string, object>>>(); }