Search in sources :

Example 1 with Asset

use of com.rbmhtechnology.vind.solr.backend.utils.Asset in project vind by RBMHTechnology.

the class SolrSearchServerTest method testExecute.

@Test
public void testExecute() throws Exception {
    Asset asset = new Asset();
    // FIXME: Asset has no @Id field
    server.indexBean(asset);
    // query
    BeanSearchResult<Asset> result = server.execute(Search.fulltext("hello world").filter(eq("category", "test")), Asset.class);
    // suggestion
    SuggestionResult suggestions = server.execute(Search.suggest("he").fields("category"), Asset.class);
    FieldDescriptor<String> title = new FieldDescriptorBuilder().setBoost(2).setLanguage(Language.German).buildTextField("title");
    // complex
    DocumentFactory factory = new DocumentFactoryBuilder("asset").addField(title).build();
    Document document = factory.createDoc("1234");
    server.index(document);
    // suggestion
    SuggestionResult suggestionsFromFactory = server.execute(Search.suggest("he").fields("title"), factory);
}
Also used : DocumentFactory(com.rbmhtechnology.vind.model.DocumentFactory) SuggestionResult(com.rbmhtechnology.vind.api.result.SuggestionResult) Asset(com.rbmhtechnology.vind.solr.backend.utils.Asset) Document(com.rbmhtechnology.vind.api.Document) FieldDescriptorBuilder(com.rbmhtechnology.vind.model.FieldDescriptorBuilder) DocumentFactoryBuilder(com.rbmhtechnology.vind.model.DocumentFactoryBuilder) Test(org.junit.Test)

Aggregations

Document (com.rbmhtechnology.vind.api.Document)1 SuggestionResult (com.rbmhtechnology.vind.api.result.SuggestionResult)1 DocumentFactory (com.rbmhtechnology.vind.model.DocumentFactory)1 DocumentFactoryBuilder (com.rbmhtechnology.vind.model.DocumentFactoryBuilder)1 FieldDescriptorBuilder (com.rbmhtechnology.vind.model.FieldDescriptorBuilder)1 Asset (com.rbmhtechnology.vind.solr.backend.utils.Asset)1 Test (org.junit.Test)1