Esempio n. 1
0
        private IList <int> Search(string text, int tipodocumentoId, string startDate, string endDate)
        {
            var directory   = this.GetDirectory();
            var indexReader = this.GetIndexReader(directory);
            var searcher    = new IndexSearcher(indexReader);

            try
            {
                var query  = this.BuildQuery(text, tipodocumentoId);
                var filter = this.BuildDateFilter(startDate, endDate);

                var sort = new Sort(new SortField("dataCriacao", SortField.LONG, true));

                var docs = searcher.Search(query, filter, this.configuracoesDaAplicacao.ResultadoMaximoConsulta, sort);

                // create highlighter
                var formatter = new SimpleHTMLFormatter("<span class=\"result-highlight\">", "</span>");
                var scorer    = new QueryScorer(query);
                this.Highlighter = new Highlighter(formatter, scorer);
                this.Stream      = LuceneEngineBase.GetAnalyzer().TokenStream(string.Empty, new StringReader(text));

                return(this.BuildSearchResult(docs, searcher));
            }
            finally
            {
                searcher.Dispose();
                indexReader.Dispose();
                directory.Dispose();
            }
        }
Esempio n. 2
0
 protected IndexWriter GetIndexWriter(FSDirectory directory)
 {
     return(new IndexWriter(
                this.GetDirectory(),
                LuceneEngineBase.GetAnalyzer(),
                IndexWriter.MaxFieldLength.UNLIMITED));
 }
Esempio n. 3
0
        private Query GetParsedQuery(string queryText)
        {
            var queryParser = new QueryParser(
                LuceneEngineBase.GetVersion(), "assunto", LuceneEngineBase.GetAnalyzer())
            {
                AllowLeadingWildcard = true
            };

            return(queryParser.Parse(queryText));
        }
Esempio n. 4
0
        public LuceneIndexerSession Begin(string indexDirectory)
        {
            Log.App.DebugFormat("Abrindo indice em {0}", indexDirectory);

            directory = FSDirectory.Open(new DirectoryInfo(indexDirectory));

            writer = new IndexWriter(
                directory,
                LuceneEngineBase.GetAnalyzer(),
                IndexWriter.MaxFieldLength.UNLIMITED);

            return(this);
        }
Esempio n. 5
0
 public static Analyzer GetAnalyzer()
 {
     return(new BrazilianAnalyzerCustom(LuceneEngineBase.GetVersion()));
 }