Esempio n. 1
0
        public static Query MakeQuery(string q, NuGetSearcherManager searcherManager)
        {
            Query query        = LuceneQueryCreator.Parse(q, false);
            Query boostedQuery = new RankingScoreQuery(query, searcherManager.GetRankings());

            return(boostedQuery);
        }
Esempio n. 2
0
        static Query AutoCompleteMakeQuery(string q, NuGetSearcherManager searcherManager)
        {
            if (string.IsNullOrEmpty(q))
            {
                return(new MatchAllDocsQuery());
            }

            QueryParser queryParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, "IdAutocomplete", new PackageAnalyzer());

            //TODO: we should be doing phrase queries to get the ordering right
            //const int MAX_NGRAM_LENGTH = 8;
            //q = (q.Length < MAX_NGRAM_LENGTH) ? q : q.Substring(0, MAX_NGRAM_LENGTH);
            //string phraseQuery = string.Format("IdAutocompletePhrase:\"/ {0}\"~20", q);
            //Query query = queryParser.Parse(phraseQuery);

            Query query = queryParser.Parse(q);

            Query boostedQuery = new RankingScoreQuery(query, searcherManager.GetRankings());

            return(boostedQuery);
        }