Package org.apache.lucene.queryParser.standard

Examples of org.apache.lucene.queryParser.standard.MultiFieldQueryParserWrapper


    }
  }

  public void testAnalyzerReturningNull() throws ParseException {
    String[] fields = new String[] { "f1", "f2", "f3" };
    MultiFieldQueryParserWrapper parser = new MultiFieldQueryParserWrapper(
        fields, new AnalyzerReturningNull());
    Query q = parser.parse("bla AND blo");
    assertEquals("+(f2:bla f3:bla) +(f2:blo f3:blo)", q.toString());
    // the following queries are not affected as their terms are not analyzed
    // anyway:
    q = parser.parse("bla*");
    assertEquals("f1:bla* f2:bla* f3:bla*", q.toString());
    q = parser.parse("bla~");
    assertEquals("f1:bla~0.5 f2:bla~0.5 f3:bla~0.5", q.toString());
    q = parser.parse("[a TO c]");
    assertEquals("f1:[a TO c] f2:[a TO c] f3:[a TO c]", q.toString());
  }
View Full Code Here


    doc.add(newField("body", "blah the footest blah", Field.Store.NO,
        Field.Index.ANALYZED));
    iw.addDocument(doc);
    iw.close();

    MultiFieldQueryParserWrapper mfqp = new MultiFieldQueryParserWrapper(
        new String[] { "body" }, analyzer);
    mfqp.setDefaultOperator(QueryParserWrapper.Operator.AND);
    Query q = mfqp.parse("the footest");
    IndexSearcher is = new IndexSearcher(ramDir, true);
    ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
    assertEquals(1, hits.length);
    is.close();
    ramDir.close();
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryParser.standard.MultiFieldQueryParserWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.