Example #1
0
        public static int GetCount(string type, string channelid, string classid, string year, string keywords, string groupname, out Dictionary <string, int> groupAggregate)
        {
            if (keywords.Length == 0)
            {
                keywords = "jUmBoT";
            }
            DateTime arg_15_0 = DateTime.Now;

            string[] array = type.Split(new char[]
            {
                ','
            });
            int num = array.Length;

            IndexSearcher[] array2 = new IndexSearcher[num];
            for (int i = 0; i < num; i++)
            {
                array2[i] = new IndexSearcher(HttpContext.Current.Server.MapPath("~/data/index/" + array[i] + "/"));
            }
            MultiSearcher multiSearcher = new MultiSearcher(array2);
            BooleanQuery  booleanQuery  = new BooleanQuery();

            if (channelid != "0")
            {
                Term      t     = new Term("channelid", channelid);
                TermQuery query = new TermQuery(t);
                booleanQuery.Add(query, BooleanClause.Occur.MUST);
            }
            if (Validator.StrToInt(year, 0) > 1900)
            {
                Term      t2     = new Term("year", year);
                TermQuery query2 = new TermQuery(t2);
                booleanQuery.Add(query2, BooleanClause.Occur.MUST);
            }
            string[] fields = new string[]
            {
                "title",
                "tags",
                "summary",
                "content",
                "fornull"
            };
            MultiFieldQueryParser multiFieldQueryParser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
            Query query3 = multiFieldQueryParser.Parse(keywords);

            booleanQuery.Add(query3, BooleanClause.Occur.MUST);
            Hits hits = multiSearcher.Search(booleanQuery);

            if (num == 1)
            {
                groupAggregate = SimpleFacets.Facet(booleanQuery, array2[0], groupname);
            }
            else
            {
                groupAggregate = null;
            }
            return(hits.Length());
        }
Example #2
0
        public static int GetCount(string type, string channelid, string classid, string year, string keywords, string groupname, out Dictionary <string, int> groupAggregate)
        {
            if (keywords.Length == 0)
            {
                keywords = "jUmBoT";
            }
            DateTime now = DateTime.Now;

            string[] strArray = type.Split(',');
            int      length   = strArray.Length;

            IndexSearcher[] indexSearcherArray = new IndexSearcher[length];
            for (int index = 0; index < length; ++index)
            {
                indexSearcherArray[index] = new IndexSearcher(HttpContext.Current.Server.MapPath("~/data/index/" + strArray[index] + "/"));
            }
            MultiSearcher multiSearcher = new MultiSearcher((Searchable[])indexSearcherArray);
            BooleanQuery  booleanQuery  = new BooleanQuery();

            if (channelid != "0")
            {
                TermQuery termQuery = new TermQuery(new Term(nameof(channelid), channelid));
                booleanQuery.Add((Query)termQuery, BooleanClause.Occur.MUST);
            }
            if (Validator.StrToInt(year, 0) > 1900)
            {
                TermQuery termQuery = new TermQuery(new Term(nameof(year), year));
                booleanQuery.Add((Query)termQuery, BooleanClause.Occur.MUST);
            }
            Query query = new MultiFieldQueryParser(new string[5]
            {
                "title",
                "tags",
                "summary",
                "content",
                "fornull"
            }, (Analyzer) new StandardAnalyzer()).Parse(keywords);

            booleanQuery.Add(query, BooleanClause.Occur.MUST);
            Hits hits = multiSearcher.Search((Query)booleanQuery);

            groupAggregate = length != 1 ? (Dictionary <string, int>)null : SimpleFacets.Facet((Query)booleanQuery, indexSearcherArray[0], groupname);
            return(hits.Length());
        }