NOTE: THE CONTENT TEXT DOES NOT CONTAIN THE ROOT WORDS, THIS IS JUST THE REFERENCE TEXT SHOWING HOW SHOULD WORKS!!
*/
//Testing the stemer
SiteSearchResults siteSearchResults = siteSearchAPI.search( indexName, "argu", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertTrue( siteSearchResults.getTotalResults() > 0 );
String highLights = siteSearchResults.getResults().get( 0 ).getHighLights()[0];
assertTrue( highLights.contains( "<em>argue</em>" ) );
assertTrue( highLights.contains( "<em>argued</em>" ) );
assertTrue( highLights.contains( "<em>argues</em>" ) );
assertTrue( highLights.contains( "<em>arguing</em>" ) );
//assertTrue( highLights.contains( "<em>argus</em>" ) );//Not found..., verify this....
//Testing the stemer
siteSearchResults = siteSearchAPI.search( indexName, "cats", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertTrue( siteSearchResults.getTotalResults() > 0 );
highLights = siteSearchResults.getResults().get( 0 ).getHighLights()[0];
assertTrue( highLights.contains( "<em>cat</em>" ) );
//Testing the stemer
siteSearchResults = siteSearchAPI.search( indexName, "stem", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertTrue( siteSearchResults.getTotalResults() > 0 );
highLights = siteSearchResults.getResults().get( 0 ).getHighLights()[0];
//assertTrue( highLights.contains( "<em>stemmer</em>" ) );//Not found..., verify this....
assertTrue( highLights.contains( "<em>stemming</em>" ) );
assertTrue( highLights.contains( "<em>stemmed</em>" ) );
//Testing the stemer
siteSearchResults = siteSearchAPI.search( indexName, "argument", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertTrue( siteSearchResults.getTotalResults() > 0 );
highLights = siteSearchResults.getResults().get( 0 ).getHighLights()[0];
assertTrue( highLights.contains( "<em>arguments</em>" ) );
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++NGrams++++++++++++++++++++++++++
//Testing the search with words that are in each extreme of the text
siteSearchResults = siteSearchAPI.search( indexName, "english illustrating", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertTrue( siteSearchResults.getTotalResults() > 0 );
//Testing the search with words that are not in find order
siteSearchResults = siteSearchAPI.search( indexName, "arguments algorithm", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertTrue( siteSearchResults.getTotalResults() > 0 );
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++OTHER TESTS+++++++++++++++++++++++
//Testing the search
siteSearchResults = siteSearchAPI.search( indexName, "engli*", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertTrue( siteSearchResults.getTotalResults() > 0 );
//Testing the search
siteSearchResults = siteSearchAPI.search( indexName, "*engli", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertEquals( siteSearchResults.getTotalResults(), 0 );
//Testing the search
siteSearchResults = siteSearchAPI.search( indexName, "e", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertEquals( siteSearchResults.getTotalResults(), 0 );
//Testing the search with a non existing word
siteSearchResults = siteSearchAPI.search( indexName, "weird", 0, 100 );
//Validations
assertTrue( siteSearchResults.getError() == null || siteSearchResults.getError().isEmpty() );
assertEquals( siteSearchResults.getTotalResults(), 0 );
} finally {
//And finally remove the index
siteSearchAPI.deleteFromIndex( indexName, docId );
}
}