use of com.rbmhtechnology.vind.model.DocumentFactory in project vind by RBMHTechnology.
the class SolrSearchServerTest method testExecuteReal.
// is ignored because tests (and therefor requires) a remote solr server
@Test
@Ignore
public void testExecuteReal() throws Exception {
SearchConfiguration.set(SearchConfiguration.SERVER_HOST, "http://localhost:8983/solr/searchindex");
SearchServer server = SearchServer.getInstance();
FieldDescriptor<String> title = new FieldDescriptorBuilder().setBoost(2).setLanguage(Language.German).buildTextField("title");
DocumentFactory factory = new DocumentFactoryBuilder("asset").addField(title).build();
server.index(factory.createDoc("1").setValue(title, "Hello World"));
server.commit();
assertEquals(1, server.execute(Search.fulltext(), factory).getNumOfResults());
}
use of com.rbmhtechnology.vind.model.DocumentFactory 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"));
}
use of com.rbmhtechnology.vind.model.DocumentFactory in project vind by RBMHTechnology.
the class MonitoringSearchServerTest method testSuggestionQueryMonitoringWithSessionAndLogger.
@Test
public void testSuggestionQueryMonitoringWithSessionAndLogger() throws IOException {
TestMonitoringWriter logger = new TestMonitoringWriter();
MonitoringSearchServer server = new MonitoringSearchServer(testSearchServer.getSearchServer(), new SimpleApplication("app"), new SimpleSession("123"), logger);
final SingleValueFieldDescriptor.TextFieldDescriptor<String> textField = new FieldDescriptorBuilder<String>().setFacet(true).buildTextField("textField");
final DocumentFactory factory = new DocumentFactoryBuilder("asset").addField(textField).build();
server.execute(Search.fulltext(), factory);
server.setSession(new SimpleSession("456"));
server.execute(Search.fulltext("Hello World").filter(or(eq(textField, "testFilter"), not(prefix("textField", "pref")))).facet(textField).sort(Sort.desc(textField)), factory);
// logger.logs.get(1).toJson();
assertEquals(2, logger.logs.size());
assertEquals("app", ((SimpleApplication) logger.logs.get(0).getApplication()).getId());
assertEquals("123", logger.logs.get(0).getSession().getSessionId());
assertEquals("*", ((FullTextEntry) logger.logs.get(0)).getRequest().getQuery());
assertEquals("456", logger.logs.get(1).getSession().getSessionId());
assertEquals("*", ((FullTextEntry) logger.logs.get(0)).getRequest().getQuery());
}
use of com.rbmhtechnology.vind.model.DocumentFactory in project vind by RBMHTechnology.
the class SolrSearchServer method getRawQuery.
@Override
public <T> String getRawQuery(ExecutableSuggestionSearch search, Class<T> c) {
final DocumentFactory factory = AnnotationUtil.createDocumentFactory(c);
final SolrQuery query = buildSolrQuery(search, factory, null);
return query.toString();
}
use of com.rbmhtechnology.vind.model.DocumentFactory in project vind by RBMHTechnology.
the class SolrSearchServer method execute.
@Override
public <T> BeanSearchResult<T> execute(FulltextSearch search, Class<T> c) {
final DocumentFactory factory = AnnotationUtil.createDocumentFactory(c);
final SearchResult docResult = this.execute(search, factory);
return docResult.toPojoResult(docResult, c);
}
Aggregations