Package org.apache.lucene.queryparser.classic

Examples of org.apache.lucene.queryparser.classic.QueryParser$LookaheadSuccess


  }

  private void checkMatches(String qString, String expectedVals)
      throws Exception {
    QueryParser qp = new ComplexPhraseQueryParser(TEST_VERSION_CURRENT, defaultFieldName, analyzer);
    qp.setFuzzyPrefixLength(1); // usually a good idea

    Query q = qp.parse(qString);

    HashSet<String> expecteds = new HashSet<String>();
    String[] vals = expectedVals.split(",");
    for (int i = 0; i < vals.length; i++) {
      if (vals[i].length() > 0)
View Full Code Here


      cache.clear();
   }
  
   @Test
   public void searchOnEmptyIndex() throws ParseException {
      QueryParser queryParser = TestQueryHelperFactory.createQueryParser("countryName");
      Query query = queryParser.parse("Italy");
      List<Object> list = qf.getQuery(query, Country.class, City.class).list();
      assertEquals(0, list.size());
   }
View Full Code Here

      assertEquals(0, list.size());
   }
  
   @Test
   public void searchOnAllTypes() throws ParseException {
      QueryParser queryParser = TestQueryHelperFactory.createQueryParser("countryName");
      Query query = queryParser.parse("Italy");
      Country italy = new Country();
      italy.countryName = "Italy";
      cache.put("IT", italy);
      List<Object> list = qf.getQuery(query, Country.class, City.class).list();
      assertEquals(1, list.size());
View Full Code Here

      assertEquals(1, list.size());
   }
  
   @Test
   public void searchOnSimpleField() throws ParseException {
      QueryParser queryParser = TestQueryHelperFactory.createQueryParser("countryName");
      Query query = queryParser.parse("Italy");
      Country italy = new Country();
      italy.countryName = "Italy";
      cache.put("IT", italy);
      List<Object> list = qf.getQuery(query, Country.class, City.class).list();
      assertEquals(1, list.size());
View Full Code Here

      assertEquals(1, list.size());
   }
  
   @Test
   public void searchOnEmbeddedField() throws ParseException {
      QueryParser queryParser = TestQueryHelperFactory.createQueryParser("cities.name");
      Query query = queryParser.parse("Newcastle");
     
      Country uk = new Country();
      City london = new City();
      london.name = "London";
      City newcastle = new City();
View Full Code Here

public class TestQueryHelperFactory {
  
   public static final Analyzer STANDARD_ANALYZER = new StandardAnalyzer(getLuceneVersion());
  
   public static QueryParser createQueryParser(String defaultFieldName) {
      return new QueryParser(getLuceneVersion(), defaultFieldName, STANDARD_ANALYZER);
   }
View Full Code Here

   public static Version getLuceneVersion() {
      return Version.LUCENE_48; //Change as needed
   }

   public static CacheQuery createCacheQuery(Cache m_cache, String fieldName, String searchString) throws ParseException {
      QueryParser qp = createQueryParser(fieldName);
      Query parsedQuery = qp.parse(searchString);
      SearchManager queryFactory = Search.getSearchManager(m_cache);
      CacheQuery cacheQuery = queryFactory.getQuery(parsedQuery);
      return cacheQuery;
   }
View Full Code Here

   @Test(expectedExceptions = UnsupportedOperationException.class, expectedExceptionsMessageRegExp = "Clustered queries do not support timeouts yet.")
   public void testClusteredQueryCacheTimeout() throws Exception {
      SearchManager searchManager = Search.getSearchManager(cache1);

      QueryParser queryParser = createQueryParser("bar");

      org.apache.lucene.search.Query luceneQuery = queryParser.parse("fakebar");
      CacheQuery query = searchManager.getClusteredQuery(luceneQuery, Foo.class);
      query.timeout( 1, TimeUnit.NANOSECONDS );
   }
View Full Code Here

*/
@Test(groups = "functional", testName = "query.distributed.ClusteredQueryMassIndexingTest")
public class ClusteredQueryMassIndexingTest extends DistributedMassIndexingTest {

   protected void verifyFindsCar(Cache cache, int expectedCount, String carMake) {
      QueryParser queryParser = createQueryParser("make");

      try {
         Query luceneQuery = queryParser.parse(carMake);
         CacheQuery cacheQuery = Search.getSearchManager(cache).getClusteredQuery(luceneQuery, Car.class);

         Assert.assertEquals(expectedCount, cacheQuery.getResultSize());
      } catch(ParseException ex) {
         ex.printStackTrace();
View Full Code Here

         caches.add(cache);
      }
   }

   protected void verifyFindsCar(Cache cache, int count, String carMake) {
      QueryParser queryParser = createQueryParser("make");

      try {
         Query luceneQuery = queryParser.parse(carMake);
         CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery, Car.class);

         assertEquals(count, cacheQuery.getResultSize());

      } catch(ParseException ex) {
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryparser.classic.QueryParser$LookaheadSuccess

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.