/// <summary>
        /// Prepare the queries for this test.
        /// Extending classes can override this method for preparing different queries.
        /// </summary>
        /// <returns>Prepared queries.</returns>
        /// <exception cref="System.Exception">If cannot prepare the queries.</exception>
        protected override Query[] PrepareQueries()
        {
            // analyzer (default is standard analyzer)
            Analyzer anlzr = NewAnalyzerTask.CreateAnalyzer(m_config.Get("analyzer",
                                                                         "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net.Analysis.Common"));

            QueryParser qp = new QueryParser(
#pragma warning disable 612, 618
                LuceneVersion.LUCENE_CURRENT,
#pragma warning restore 612, 618
                DocMaker.BODY_FIELD, anlzr);
            List <Query> qq = new List <Query>();
            Query        q1 = new TermQuery(new Term(DocMaker.ID_FIELD, "doc2"));

            qq.Add(q1);
            Query q2 = new TermQuery(new Term(DocMaker.BODY_FIELD, "simple"));

            qq.Add(q2);
            BooleanQuery bq = new BooleanQuery();

            bq.Add(q1, Occur.MUST);
            bq.Add(q2, Occur.MUST);
            qq.Add(bq);
            qq.Add(qp.Parse("synthetic body"));
            qq.Add(qp.Parse("\"synthetic body\""));
            qq.Add(qp.Parse("synthetic text"));
            qq.Add(qp.Parse("\"synthetic text\""));
            qq.Add(qp.Parse("\"synthetic text\"~3"));
            qq.Add(qp.Parse("zoom*"));
            qq.Add(qp.Parse("synth*"));
            return(qq.ToArray());
        }
Beispiel #2
0
        public virtual void SetConfig(Config config)
        {
            Analyzer anlzr = NewAnalyzerTask.CreateAnalyzer(config.Get("analyzer", typeof(StandardAnalyzer).Name));

            m_parser = new QueryParser(
#pragma warning disable 612, 618
                LuceneVersion.LUCENE_CURRENT,
#pragma warning restore 612, 618
                DocMaker.BODY_FIELD, anlzr);
        }
Beispiel #3
0
        protected override Query[] PrepareQueries()
        {
            // analyzer (default is standard analyzer)
            Analyzer anlzr = NewAnalyzerTask.CreateAnalyzer(m_config.Get("analyzer",
                                                                         typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).AssemblyQualifiedName));

            JCG.List <object> queryList = new JCG.List <object>(20);
            queryList.AddRange(STANDARD_QUERIES);
            queryList.AddRange(GetPrebuiltQueries(DocMaker.BODY_FIELD));
            return(CreateQueries(queryList, anlzr));
        }
        protected override Query[] PrepareQueries()
        {
            // analyzer (default is standard analyzer)
            Analyzer anlzr = NewAnalyzerTask.CreateAnalyzer(m_config.Get("analyzer",
                                                                         "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net.Analysis.Common"));

            List <object> queryList = new List <object>(20);

            queryList.AddRange(STANDARD_QUERIES);
            queryList.AddRange(GetPrebuiltQueries(DocMaker.BODY_FIELD));
            return(CreateQueries(queryList, anlzr));
        }
Beispiel #5
0
        protected override Query[] PrepareQueries()
        {
            // analyzer (default is standard analyzer)
            Analyzer anlzr = NewAnalyzerTask.CreateAnalyzer(m_config.Get("analyzer", typeof(StandardAnalyzer).AssemblyQualifiedName));

            JCG.List <object> queryList = new JCG.List <object>(20);
            queryList.AddRange(STANDARD_QUERIES);
            if (!m_config.Get("enwikiQueryMaker.disableSpanQueries", false))
            {
                queryList.AddRange(GetPrebuiltQueries(DocMaker.BODY_FIELD));
            }
            return(CreateQueries(queryList, anlzr));
        }
Beispiel #6
0
        // constructor
        public PerfRunData(Config config)
        {
            this.config = config;
            // analyzer (default is standard analyzer)
            analyzer = NewAnalyzerTask.CreateAnalyzer(config.Get("analyzer",
                                                                 typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).AssemblyQualifiedName));

            // content source
            string sourceClass = config.Get("content.source", typeof(SingleDocSource).AssemblyQualifiedName);

            contentSource = (ContentSource)Activator.CreateInstance(Type.GetType(sourceClass)); //Class.forName(sourceClass).asSubclass(typeof(ContentSource)).newInstance();
            contentSource.SetConfig(config);

            // doc maker
            docMaker = (DocMaker)Activator.CreateInstance(Type.GetType(config.Get("doc.maker", typeof(DocMaker).AssemblyQualifiedName)));  // "org.apache.lucene.benchmark.byTask.feeds.DocMaker")).asSubclass(DocMaker.class).newInstance();
            docMaker.SetConfig(config, contentSource);
            // facet source
            facetSource = (FacetSource)Activator.CreateInstance(Type.GetType(config.Get("facet.source",
                                                                                        typeof(RandomFacetSource).AssemblyQualifiedName))); // "org.apache.lucene.benchmark.byTask.feeds.RandomFacetSource")).asSubclass(FacetSource.class).newInstance();
            facetSource.SetConfig(config);
            // query makers
            readTaskQueryMaker = new Dictionary <Type, IQueryMaker>();
            qmkrClass          = Type.GetType(config.Get("query.maker", typeof(SimpleQueryMaker).AssemblyQualifiedName));

            // index stuff
            Reinit(false);

            // statistic points
            points = new Points(config);

            if (bool.Parse(config.Get("log.queries", "false")))
            {
                Console.WriteLine("------------> queries:");
                Console.WriteLine(GetQueryMaker(new SearchTask(this)).PrintQueries());
            }
        }
        protected override Query[] PrepareQueries()
        {
            Analyzer anlzr = NewAnalyzerTask.CreateAnalyzer(m_config.Get("analyzer",
                                                                         typeof(Lucene.Net.Analysis.Standard.StandardAnalyzer).AssemblyQualifiedName));
            string      defaultField = m_config.Get("file.query.maker.default.field", DocMaker.BODY_FIELD);
            QueryParser qp           = new QueryParser(
#pragma warning disable 612, 618
                LuceneVersion.LUCENE_CURRENT,
#pragma warning restore 612, 618
                defaultField, anlzr);

            qp.AllowLeadingWildcard = true;

            List <Query> qq       = new List <Query>();
            string       fileName = m_config.Get("file.query.maker.file", null);

            if (fileName != null)
            {
                FileInfo   file   = new FileInfo(fileName);
                TextReader reader = null;
                // note: we use a decoding reader, so if your queries are screwed up you know
                if (file.Exists)
                {
                    reader = IOUtils.GetDecodingReader(file, Encoding.UTF8);
                }
                else
                {
                    //see if we can find it as a resource
                    Stream asStream = typeof(FileBasedQueryMaker).FindAndGetManifestResourceStream(fileName);
                    if (asStream != null)
                    {
                        reader = IOUtils.GetDecodingReader(asStream, Encoding.UTF8);
                    }
                }
                if (reader != null)
                {
                    try
                    {
                        string line    = null;
                        int    lineNum = 0;
                        while ((line = reader.ReadLine()) != null)
                        {
                            line = line.Trim();
                            if (line.Length != 0 && !line.StartsWith("#", StringComparison.Ordinal))
                            {
                                try
                                {
                                    qq.Add(qp.Parse(line));
                                }
                                catch (ParseException e)
                                {
                                    Console.Error.WriteLine("Exception: " + e.Message + " occurred while parsing line: " + lineNum + " Text: " + line);
                                }
                            }
                            lineNum++;
                        }
                    }
                    finally
                    {
                        reader.Dispose();
                    }
                }
                else
                {
                    Console.Error.WriteLine("No Reader available for: " + fileName);
                }
            }
            return(qq.ToArray());
        }