コード例 #1
0
        public virtual void  TestStaticMethod2Old()
        {
            System.String[] fields = new System.String[] { "b", "t" };
            //int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
            BooleanClause.Occur[] flags  = new BooleanClause.Occur[] { BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT };
            MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());

            Query q = MultiFieldQueryParser.Parse("one", fields, flags, new StandardAnalyzer());             //, fields, flags, new StandardAnalyzer());

            Assert.AreEqual("+b:one -t:one", q.ToString());

            q = MultiFieldQueryParser.Parse("one two", fields, flags, new StandardAnalyzer());
            Assert.AreEqual("+(b:one b:two) -(t:one t:two)", q.ToString());

            try
            {
                BooleanClause.Occur[] flags2 = new BooleanClause.Occur[] { BooleanClause.Occur.MUST };
                q = MultiFieldQueryParser.Parse("blah", fields, flags2, new StandardAnalyzer());
                Assert.Fail();
            }
            catch (System.ArgumentException e)
            {
                // expected exception, array length differs
            }
        }
コード例 #2
0
        public virtual void  TestStaticMethod3Old()
        {
            System.String[]       queries = new System.String[] { "one", "two" };
            System.String[]       fields  = new System.String[] { "b", "t" };
            BooleanClause.Occur[] flags   = new BooleanClause.Occur[] { BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT };
            Query q = MultiFieldQueryParser.Parse(queries, fields, flags, new StandardAnalyzer());

            Assert.AreEqual("+b:one -t:two", q.ToString());

            try
            {
                BooleanClause.Occur[] flags2 = new BooleanClause.Occur[] { BooleanClause.Occur.MUST };
                q = MultiFieldQueryParser.Parse(queries, fields, flags2, new StandardAnalyzer());
                Assert.Fail();
            }
            catch (System.ArgumentException e)
            {
                // expected exception, array length differs
            }
        }
コード例 #3
0
		public virtual void  TestStaticMethod3Old()
		{
			System.String[] queries = new System.String[]{"one", "two"};
			System.String[] fields = new System.String[]{"b", "t"};
			BooleanClause.Occur[] flags = new BooleanClause.Occur[]{BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
			Query q = MultiFieldQueryParser.Parse(queries, fields, flags, new StandardAnalyzer());
			Assert.AreEqual("+b:one -t:two", q.ToString());
			
			try
			{
				BooleanClause.Occur[] flags2 = new BooleanClause.Occur[]{BooleanClause.Occur.MUST};
				q = MultiFieldQueryParser.Parse(queries, fields, flags2, new StandardAnalyzer());
				Assert.Fail();
			}
			catch (System.ArgumentException e)
			{
				// expected exception, array length differs
			}
		}
コード例 #4
0
		public virtual void  TestStaticMethod2Old()
		{
			System.String[] fields = new System.String[]{"b", "t"};
			//int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
			BooleanClause.Occur[] flags = new BooleanClause.Occur[]{BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
			MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
			
			Query q = MultiFieldQueryParser.Parse("one", fields, flags, new StandardAnalyzer()); //, fields, flags, new StandardAnalyzer());
			Assert.AreEqual("+b:one -t:one", q.ToString());
			
			q = MultiFieldQueryParser.Parse("one two", fields, flags, new StandardAnalyzer());
			Assert.AreEqual("+(b:one b:two) -(t:one t:two)", q.ToString());
			
			try
			{
				BooleanClause.Occur[] flags2 = new BooleanClause.Occur[]{BooleanClause.Occur.MUST};
				q = MultiFieldQueryParser.Parse("blah", fields, flags2, new StandardAnalyzer());
				Assert.Fail();
			}
			catch (System.ArgumentException e)
			{
				// expected exception, array length differs
			}
		}