@Test
 public void testWithNamespace() throws Exception {
   factoryBean.setNamespace("myNamespace");
   factoryBean.afterPropertiesSet();
   SearchService searchService = factoryBean.getObject();
   assertEquals("myNamespace", searchService.getNamespace());
 }
Esempio n. 2
0
 @PostConstruct
 private void loadRows() {
   rows = new ArrayList<Row>();
   try {
     NamespaceManager.validateNamespace(namespace);
   } catch (Exception e) {
     errorMessage = e.getMessage();
     return;
   }
   NamespaceManager.set(namespace);
   try {
     SearchService search = SearchServiceFactory.getSearchService(namespace);
     GetResponse<Index> response =
         search.getIndexes(
             GetIndexesRequest.newBuilder().setIndexNamePrefix(indexNamePrefix).build());
     for (Index index : response.getResults()) {
       rows.add(new Row(index));
     }
   } finally {
     NamespaceManager.set("");
   }
 }
Esempio n. 3
0
 /**
  * Shortcut notation to easily get an index from the search service.
  *
  * <pre><code>
  *     def index = search.index("books")
  * </code></pre>
  *
  * @param search the search service
  * @param indexName the name of the index
  * @return an index
  */
 public static Index index(SearchService search, String indexName) {
   return search.getIndex(IndexSpec.newBuilder().setName(indexName).build());
 }
Esempio n. 4
0
 /** Extension point allowing the Index implementation to be modified */
 protected Index getIndex() {
   SearchService searchService = SearchServiceFactory.getSearchService();
   return searchService.getIndex(IndexSpec.newBuilder().setName(indexName));
 }