use of com.rbmhtechnology.vind.solr.backend.SolrSearchServer in project vind by RBMHTechnology.
the class IntervalFacetsTest method testQueryBuilder.
@Test
public void testQueryBuilder() {
SolrClient client = Mockito.mock(SolrClient.class);
SolrSearchServer server = new SolrSearchServer(client, false);
FieldDescriptor<Integer> descriptor = Mockito.mock(FieldDescriptor.class);
when(descriptor.getType()).thenReturn(Integer.class);
when(descriptor.isFacet()).thenReturn(true);
DocumentFactory factory = Mockito.mock(DocumentFactory.class);
FulltextSearch search = Search.fulltext().facet(interval("quality", descriptor, Interval.numericInterval("low", 0, 2, true, false), Interval.numericInterval("high", 3, 4)));
SolrQuery query = server.buildSolrQuery(search, factory);
assertEquals("{!key=quality}dynamic_single_facet_int_null", query.get("facet.interval"));
// assertThat(Arrays.asList(query.getParams("f.dynamic_single_int_null.facet.interval.set")), contains("{!key=low}[0,2)", "{!key=high}[3,4]")); TODO fix hamcrest dependency
}
use of com.rbmhtechnology.vind.solr.backend.SolrSearchServer in project vind by RBMHTechnology.
the class SuggestionTest method testSpellcheck.
@Test
public void testSpellcheck() {
SolrClient client = Mockito.mock(SolrClient.class);
SolrSearchServer server = new SolrSearchServer(client, false);
FieldDescriptor descriptor = Mockito.mock(FieldDescriptor.class);
when(descriptor.getType()).thenReturn(String.class);
when(descriptor.isSuggest()).thenReturn(true);
DocumentFactory factory = Mockito.mock(DocumentFactory.class);
when(factory.getField(any())).thenReturn(descriptor);
ExecutableSuggestionSearch search = Search.suggest("abc").fields("field");
SolrQuery query = server.buildSolrQuery(search, factory, null);
assertEquals("abc", query.get("q"));
assertEquals("dynamic_single_suggest_string_null", query.get("suggestion.field"));
assertEquals(SolrSearchServer.SUGGESTION_DF_FIELD, query.get("suggestion.df"));
assertEquals("10", query.get("suggestion.limit"));
search.setLimit(100);
query = server.buildSolrQuery(search, factory, null);
assertEquals("100", query.get("suggestion.limit"));
ExecutableSuggestionSearch search2 = Search.suggest("abc").fields(descriptor).clearFilter();
query = server.buildSolrQuery(search2, factory, null);
assertEquals("10", query.get("suggestion.limit"));
}
Aggregations