Search in sources :

Example 1 with SolrSearchServer

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
}
Also used : DocumentFactory(com.rbmhtechnology.vind.model.DocumentFactory) SolrClient(org.apache.solr.client.solrj.SolrClient) SolrSearchServer(com.rbmhtechnology.vind.solr.backend.SolrSearchServer) FulltextSearch(com.rbmhtechnology.vind.api.query.FulltextSearch) SolrQuery(org.apache.solr.client.solrj.SolrQuery) Test(org.junit.Test)

Example 2 with SolrSearchServer

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"));
}
Also used : DocumentFactory(com.rbmhtechnology.vind.model.DocumentFactory) SolrClient(org.apache.solr.client.solrj.SolrClient) SolrSearchServer(com.rbmhtechnology.vind.solr.backend.SolrSearchServer) ExecutableSuggestionSearch(com.rbmhtechnology.vind.api.query.suggestion.ExecutableSuggestionSearch) SolrQuery(org.apache.solr.client.solrj.SolrQuery) FieldDescriptor(com.rbmhtechnology.vind.model.FieldDescriptor) Test(org.junit.Test)

Aggregations

DocumentFactory (com.rbmhtechnology.vind.model.DocumentFactory)2 SolrSearchServer (com.rbmhtechnology.vind.solr.backend.SolrSearchServer)2 SolrClient (org.apache.solr.client.solrj.SolrClient)2 SolrQuery (org.apache.solr.client.solrj.SolrQuery)2 Test (org.junit.Test)2 FulltextSearch (com.rbmhtechnology.vind.api.query.FulltextSearch)1 ExecutableSuggestionSearch (com.rbmhtechnology.vind.api.query.suggestion.ExecutableSuggestionSearch)1 FieldDescriptor (com.rbmhtechnology.vind.model.FieldDescriptor)1