Lowest level base class for surround queries
Inheritance: ICloneable
Beispiel #1
0
        public void DoTest(StringBuilder failQueries)
        {
            bool      pass = false;
            SrndQuery lq   = null;

            try
            {
                lq = Parser.QueryParser.Parse(queryText);
                if (verbose)
                {
                    Console.WriteLine("Query: " + queryText + "\nParsed as: " + lq.ToString());
                }
            }
            catch (ParseException e)
            {
                if (verbose)
                {
                    Console.WriteLine("Parse exception for query:\n"
                                      + queryText + "\n"
                                      + e.Message);
                }
                pass = true;
            }
            if (!pass)
            {
                failQueries.append(queryText);
                failQueries.append("\nParsed as: ");
                failQueries.append(lq.toString());
                failQueries.append("\n");
            }
        }
Beispiel #2
0
        public void DoTest()
        {
            if (verbose)
            {
                Console.WriteLine("");
                Console.WriteLine("Query: " + queryText);
            }

            SrndQuery lq = Parser.QueryParser.Parse(queryText);

            /* if (verbose) System.out.println("Srnd: " + lq.toString()); */

            Search.Query query = lq.MakeLuceneQueryField(fieldName, qf);
            /* if (verbose) System.out.println("Lucene: " + query.toString()); */

            TestCollector tc = new TestCollector(this);

            using (IndexReader reader = DirectoryReader.Open(dBase.Db))
            {
                IndexSearcher searcher = new IndexSearcher(reader);

                searcher.Search(query, tc);
            }
            tc.CheckNrHits();
        }
 public FieldsQuery(SrndQuery q, string fieldName, char fieldOp)
 {
     this.q = q;
     var fieldNameList = new List<string>();
     fieldNameList.Add(fieldName);
     this.fieldNames = fieldNameList;
     this.fieldOp = fieldOp;
 }
Beispiel #4
0
        public FieldsQuery(SrndQuery q, string fieldName, char fieldOp)
        {
            this.q = q;
            var fieldNameList = new List <string>();

            fieldNameList.Add(fieldName);
            this.fieldNames = fieldNameList;
            this.fieldOp    = fieldOp;
        }
Beispiel #5
0
        public FieldsQuery(SrndQuery q, string fieldName, char fieldOp)
        {
            this.q = q;
            var fieldNameList = new JCG.List <string>
            {
                fieldName
            };

            this.fieldNames = fieldNameList;
            this.fieldOp    = fieldOp;
        }
Beispiel #6
0
        public virtual string DistanceSubQueryNotAllowed()
        {
            var sqi = GetSubQueriesEnumerator();

            while (sqi.MoveNext())
            {
                SrndQuery leq = sqi.Current;
                if (leq is IDistanceSubQuery distanceSubQuery)
                {
                    string m = distanceSubQuery.DistanceSubQueryNotAllowed();
                    if (m != null)
                    {
                        return(m);
                    }
                }
                else
                {
                    return("subquery not allowed: " + leq.ToString());
                }
            }
            return(null);
        }
Beispiel #7
0
 protected virtual SrndQuery GetFieldsQuery(
     SrndQuery q, IEnumerable<string> fieldNames)
 {
     /* FIXME: check acceptable subquery: at least one subquery should not be
      * a fields query.
      */
     return new FieldsQuery(q, fieldNames, fieldOperator);
 }
Beispiel #8
0
 public void OptionalWeights(SrndQuery q)
 {
     Token weight = null;
     while (true)
     {
         switch ((jj_ntk == -1) ? Jj_ntk() : jj_ntk)
         {
             case RegexpToken.CARAT:
                 ;
                 break;
             default:
                 jj_la1[9] = jj_gen;
                 goto label_8;
         }
         Jj_consume_token(RegexpToken.CARAT);
         weight = Jj_consume_token(RegexpToken.NUMBER);
         float f;
         try
         {
             // LUCENENET TODO: Test parsing float in various cultures (.NET)
             f = float.Parse(weight.image);
         }
         catch (Exception floatExc)
         {
             { if (true) throw new ParseException(boostErrorMessage + weight.image + " (" + floatExc + ")"); }
         }
         if (f <= 0.0)
         {
             { if (true) throw new ParseException(boostErrorMessage + weight.image); }
         }
         q.Weight = (f * q.Weight); /* left associative, fwiw */
     }
 label_8: ;
 }
        private readonly string OrOperatorName = "OR"; /* for expanded queries, not normally visible */

        public FieldsQuery(SrndQuery q, IEnumerable<string> fieldNames, char fieldOp)
        {
            this.q = q;
            this.fieldNames = new List<string>(fieldNames);
            this.fieldOp = fieldOp;
        }
Beispiel #10
0
        private readonly string orOperatorName = "OR"; /* for expanded queries, not normally visible */

        public FieldsQuery(SrndQuery q, IList <string> fieldNames, char fieldOp)
        {
            this.q          = q;
            this.fieldNames = fieldNames;
            this.fieldOp    = fieldOp;
        }
Beispiel #11
0
        private readonly string OrOperatorName = "OR"; /* for expanded queries, not normally visible */

        public FieldsQuery(SrndQuery q, IEnumerable <string> fieldNames, char fieldOp)
        {
            this.q          = q;
            this.fieldNames = new List <string>(fieldNames);
            this.fieldOp    = fieldOp;
        }