search/engine/impl-lucene/src/test/java/net/sf/mmm/search/engine/impl/lucene/LuceneSearchEngineTest.java
/**
   * This method creates a {@link ManagedSearchEngine} from a test-configuration
   * file that points to a search-index dedicated for this test (initially
   * created with the search-indexer). The search-index contains a historic
   * revision of the sources of <code>mmm-util-core</code>.
   */
This method creates a  ManagedSearchEngine from a test-configuration
file that points to a search-index dedicated for this test (initially
created with the search-indexer). The search-index contains a historic
revision of the sources of mmm-util-core.
This method creates a ManagedSearchEngine from a test - configuration file that points to a search - index dedicated for this test ( initially created with the search - indexer ) . The search - index contains a historic revision of the sources of mmm - util - core .
@Test
  public void testSearch() {
    String locationUrl = TestResourceHelper.getTestPath(LuceneSearchEngineTest.class, ".xml");
    SearchEngineConfigurationHolder configurationHolder = getSearchEngineConfigurationLoader()
        .loadConfiguration(locationUrl);
    ManagedSearchEngine searchEngine = getSearchEngineBuilder().createSearchEngine(
        configurationHolder);
    Assert.assertEquals(744, searchEngine.getTotalEntryCount());
    Assert.assertEquals(744, searchEngine.count("source", SOURCE_ID));
    Assert.assertEquals(744, searchEngine.count("type", "java"));
    Assert.assertEquals(0, searchEngine.count("source", "undefined"));
    SearchHit hit;
    hit = getSingleHit(searchEngine, "uri:" + STRING_UTIL_URI);
    Assert.assertEquals(5, hit.getScore(5));
    checkStringUtil(hit);
    hit = getSingleHit(searchEngine, "title:" + STRING_UTIL_TITLE);
    Assert.assertEquals(5, hit.getScore(5));
    checkStringUtil(hit);
    hit = getSingleHit(searchEngine, "id:" + STRING_UTIL_ID);
    Assert.assertEquals(5, hit.getScore(5));
    checkStringUtil(hit);
    hit = getSingleHit(searchEngine, "size:" + STRING_UTIL_SIZE);
    Assert.assertEquals(5, hit.getScore(5));
    checkStringUtil(hit);
    hit = getSingleHit(searchEngine, "size:{13924 - 14524}");
    Assert.assertEquals(5, hit.getScore(5));
    checkStringUtil(hit);
    SearchQuery query = searchEngine.getQueryBuilder().parseStandardQuery("size:[13924 - 14524]");
    SearchResultPage page = searchEngine.search(query, 20);
    Assert.assertEquals(3, page.getPageHitCount());
    Set<String> uriSet = new HashSet<String>();
    for (SearchHit searchHit : page) {
      uriSet.add(searchHit.getUri());
    }
    Assert.assertTrue(uriSet.contains(STRING_UTIL_URI));
    Assert.assertTrue(uriSet
        .contains("net/sf/mmm/util/pojo/descriptor/impl/DefaultPojoDescriptorEnhancer.java"));
    Assert.assertTrue(uriSet.contains("net/sf/mmm/util/reflect/api/CollectionReflectionUtil.java"));
  }
@ Test public void testSearch ( ) { String locationUrl = TestResourceHelper . getTestPath ( LuceneSearchEngineTest . class , ".xml" ) ; SearchEngineConfigurationHolder configurationHolder = getSearchEngineConfigurationLoader ( ) . loadConfiguration ( locationUrl ) ; ManagedSearchEngine searchEngine = getSearchEngineBuilder ( ) . createSearchEngine ( configurationHolder ) ; Assert . assertEquals ( 744 , searchEngine . getTotalEntryCount ( ) ) ; Assert . assertEquals ( 744 , searchEngine . count ( "source" , SOURCE_ID ) ) ; Assert . assertEquals ( 744 , searchEngine . count ( "type" , "java" ) ) ; Assert . assertEquals ( 0 , searchEngine . count ( "source" , "undefined" ) ) ; SearchHit hit ; hit = getSingleHit ( searchEngine , "uri:" + STRING_UTIL_URI ) ; Assert . assertEquals ( 5 , hit . getScore ( 5 ) ) ; checkStringUtil ( hit ) ; hit = getSingleHit ( searchEngine , "title:" + STRING_UTIL_TITLE ) ; Assert . assertEquals ( 5 , hit . getScore ( 5 ) ) ; checkStringUtil ( hit ) ; hit = getSingleHit ( searchEngine , "id:" + STRING_UTIL_ID ) ; Assert . assertEquals ( 5 , hit . getScore ( 5 ) ) ; checkStringUtil ( hit ) ; hit = getSingleHit ( searchEngine , "size:" + STRING_UTIL_SIZE ) ; Assert . assertEquals ( 5 , hit . getScore ( 5 ) ) ; checkStringUtil ( hit ) ; hit = getSingleHit ( searchEngine , "size:{13924 - 14524}" ) ; Assert . assertEquals ( 5 , hit . getScore ( 5 ) ) ; checkStringUtil ( hit ) ; SearchQuery query = searchEngine . getQueryBuilder ( ) . parseStandardQuery ( "size:[13924 - 14524]" ) ; SearchResultPage page = searchEngine . search ( query , 20 ) ; Assert . assertEquals ( 3 , page . getPageHitCount ( ) ) ; Set < String > uriSet = new HashSet < String > ( ) ; for ( SearchHit searchHit : page ) { uriSet . add ( searchHit . getUri ( ) ) ; } Assert . assertTrue ( uriSet . contains ( STRING_UTIL_URI ) ) ; Assert . assertTrue ( uriSet . contains ( "net/sf/mmm/util/pojo/descriptor/impl/DefaultPojoDescriptorEnhancer.java" ) ) ; Assert . assertTrue ( uriSet . contains ( "net/sf/mmm/util/reflect/api/CollectionReflectionUtil.java" ) ) ; }
This method creates a {@link ManagedSearchEngine} from a test-configuration
 file that points to a search-index dedicated for this test (initially
 created with the search-indexer).
This method creates a { @link ManagedSearchEngine } from a test - configuration file that points to a search - index dedicated for this test ( initially created with the search - indexer ) .