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;
 }
Example #2
0
 public HomeController(ICreativesRepository creativesRepository)
 {
     _creativesRepository = creativesRepository;
 }
Example #3
0
 public UserController(ICreativesRepository creativesRepository)
 {
     _creativesRepository = creativesRepository;
 }
Example #4
0
 public PictureController(ICreativesRepository creativesRepository)
 {
     _creativesRepository = creativesRepository;
 }
Example #5
0
 public ProfileController(ICreativesRepository creativesRepository)
 {
     _creativesRepository = creativesRepository;
 }