Search in sources :

Example 1 with UnproperSearch

use of com.yahoo.searchdefinition.UnproperSearch in project vespa by vespa-engine.

the class IndexedSearchCluster method deriveAllSearchDefinitions.

protected void deriveAllSearchDefinitions(List<SearchDefinitionSpec> localSearches, List<com.yahoo.searchdefinition.Search> globalSearches) {
    for (SearchDefinitionSpec spec : localSearches) {
        com.yahoo.searchdefinition.Search search = spec.getSearchDefinition().getSearch();
        if (!(search instanceof UnproperSearch)) {
            DocumentDatabase db = new DocumentDatabase(this, search.getName(), new DerivedConfiguration(search, globalSearches, deployLogger(), getRoot().getDeployState().rankProfileRegistry(), getRoot().getDeployState().getQueryProfiles().getRegistry()));
            // TODO: remove explicit adding of user configs when the complete content model is built using builders.
            db.mergeUserConfigs(spec.getUserConfigs());
            documentDbs.add(db);
        }
    }
}
Also used : DerivedConfiguration(com.yahoo.searchdefinition.derived.DerivedConfiguration) UnproperSearch(com.yahoo.searchdefinition.UnproperSearch)

Example 2 with UnproperSearch

use of com.yahoo.searchdefinition.UnproperSearch in project vespa by vespa-engine.

the class ApplicationDeployTest method testVespaModel.

@Test
public void testVespaModel() throws SAXException, IOException {
    FilesApplicationPackage app = createAppPkg(TESTDIR + "app1");
    assertThat(app.getApplicationName(), is("app1"));
    VespaModel model = new VespaModel(app);
    List<SearchDefinition> searchDefinitions = getSearchDefinitions(app);
    assertEquals(searchDefinitions.size(), 5);
    for (SearchDefinition searchDefinition : searchDefinitions) {
        Search s = searchDefinition.getSearch();
        switch(s.getName()) {
            case "music":
            case "laptop":
            case "pc":
            case "sock":
                break;
            case "product":
                assertTrue(s instanceof UnproperSearch);
                assertEquals(s.getDocument().getField("title").getDataType(), DataType.STRING);
                break;
            default:
                fail();
        }
    }
    File[] truth = new File[] { new File(TESTSDDIR + "laptop.sd"), new File(TESTSDDIR + "music.sd"), new File(TESTSDDIR + "pc.sd"), new File(TESTSDDIR + "product.sd"), new File(TESTSDDIR + "sock.sd") };
    Arrays.sort(truth);
    List<File> appSdFiles = app.getSearchDefinitionFiles();
    Collections.sort(appSdFiles);
    assertEquals(appSdFiles, Arrays.asList(truth));
    List<FilesApplicationPackage.Component> components = app.getComponents();
    assertEquals(1, components.size());
    Map<String, Bundle.DefEntry> defEntriesByName = defEntries2map(components.get(0).getDefEntries());
    assertEquals(5, defEntriesByName.size());
    Bundle.DefEntry def1 = defEntriesByName.get("test-namespace");
    assertNotNull(def1);
    assertEquals("namespace=config\nintVal int default=0", def1.contents);
    Bundle.DefEntry def2 = defEntriesByName.get("namespace-in-filename");
    assertNotNull(def2);
    assertEquals("namespace=a.b\n\ndoubleVal double default=0.0", def2.contents);
    // Check that getFilename works
    ArrayList<String> sdFileNames = new ArrayList<>();
    for (SearchDefinition sd : searchDefinitions) {
        sdFileNames.add(sd.getFilename());
    }
    Collections.sort(sdFileNames);
    assertThat(sdFileNames.get(0), is("laptop.sd"));
    assertThat(sdFileNames.get(1), is("music.sd"));
    assertThat(sdFileNames.get(2), is("pc.sd"));
    assertThat(sdFileNames.get(3), is("product.sd"));
    assertThat(sdFileNames.get(4), is("sock.sd"));
}
Also used : ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SearchDefinition(com.yahoo.vespa.model.search.SearchDefinition) UnproperSearch(com.yahoo.searchdefinition.UnproperSearch) VespaModel(com.yahoo.vespa.model.VespaModel) Search(com.yahoo.searchdefinition.Search) UnproperSearch(com.yahoo.searchdefinition.UnproperSearch) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Aggregations

UnproperSearch (com.yahoo.searchdefinition.UnproperSearch)2 Search (com.yahoo.searchdefinition.Search)1 DerivedConfiguration (com.yahoo.searchdefinition.derived.DerivedConfiguration)1 VespaModel (com.yahoo.vespa.model.VespaModel)1 SearchDefinition (com.yahoo.vespa.model.search.SearchDefinition)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 JarFile (java.util.jar.JarFile)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1