public static List<Creative> SearchCreatives(string IndexPath, string searchString, ICreativesRepository creativesRepository) { var indexSearcher = new DirectoryIndexSearcher(new DirectoryInfo(IndexPath), true); Directory directory = FSDirectory.Open(new DirectoryInfo(IndexPath)); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30); IndexReader indexReader = IndexReader.Open(directory, true); Searcher indexSearch = new IndexSearcher(indexReader); string[] fields = { "Titel", "About" }; var queryParser = new Lucene.Net.QueryParsers.MultiFieldQueryParser(Version.LUCENE_30, fields, analyzer); var query = queryParser.Parse(searchString.ToLower() + "*"); var hits = indexSearch.Search(query, indexReader.MaxDoc).ScoreDocs; List<Creative> creatives = new List<Creative>(); foreach (var hit in hits) { Document documentFromSearcher = indexSearch.Doc(hit.Doc); creatives.Add(creativesRepository.GetCreativeById(int.Parse(documentFromSearcher.Get("CreativeId")))); } indexSearch.Dispose(); directory.Dispose(); return creatives; }
public HomeController(ICreativesRepository creativesRepository) { _creativesRepository = creativesRepository; }
public UserController(ICreativesRepository creativesRepository) { _creativesRepository = creativesRepository; }
public PictureController(ICreativesRepository creativesRepository) { _creativesRepository = creativesRepository; }
public ProfileController(ICreativesRepository creativesRepository) { _creativesRepository = creativesRepository; }