/* (non-Javadoc) * @see fr.hoteia.qalingo.core.solr.service.ProductSkuSolrService#addOrUpdateProductSku(fr.hoteia.qalingo.core.domain.ProductSku) */ public void addOrUpdateProductSku( final ProductSku productSku, final MarketArea marketArea, final Retailer retailer) throws SolrServerException, IOException { if (productSku.getId() == null) { throw new IllegalArgumentException("Id cannot be blank or null."); } if (logger.isDebugEnabled()) { logger.debug("Indexing productSku " + productSku.getId()); logger.debug("Indexing productSku " + productSku.getBusinessName()); logger.debug("Indexing productSku " + productSku.getDescription()); logger.debug("Indexing productSku " + productSku.getCode()); } ProductSkuSolr productSkuSolr = new ProductSkuSolr(); productSkuSolr.setId(productSku.getId()); productSkuSolr.setBusinessname(productSku.getBusinessName()); productSkuSolr.setDescription(productSku.getDescription()); productSkuSolr.setCode(productSku.getCode()); ProductSkuPrice productSkuPrice = productSku.getPrice(marketArea.getId(), retailer.getId()); if (productSkuPrice != null) { BigDecimal salePrice = productSkuPrice.getSalePrice(); productSkuSolr.setPrice(salePrice.toString()); } productSkuSolrServer.addBean(productSkuSolr); productSkuSolrServer.commit(); }
private void index(TruckEvent truckEvent) { try { LOG.info("Starting process to solr index document[" + truckEvent + "]"); UpdateResponse response = server.addBean(truckEvent); LOG.info( "Indexed document with id: " + truckEvent.getId() + " status: " + response.getStatus()); } catch (IOException e) { LOG.error("Could not index document: " + truckEvent.getId() + " " + e.getMessage()); e.printStackTrace(); } catch (SolrServerException e) { LOG.error("Could not index document: " + truckEvent.getId() + " " + e.getMessage()); e.printStackTrace(); } }
@Before public void initSearcher() throws Exception { service = new SolrSearchService(); System.setProperty( "solr.solr.home", SolrTest.class.getClassLoader().getResource(".").getPath() + "solr-test"); SolrServer solrServer = SolrServerFactory.newEmbeddedInstance( new File( SolrTest.class.getClassLoader().getResource(".").getPath() + "/solr-test/venues/conf"), new File("/tmp/solrdataDir")); solrServer.deleteById("1"); solrServer.commit(); Venue v = new Venue(); v.setId(1l); v.setName("La nueva galicia"); v.setAddress("Calle del pozo,13"); v.setSlug("nueva-galicia"); solrServer.addBean(v); solrServer.commit(); service.setSolr(solrServer); }
@SuppressWarnings("finally") public boolean insertMediaItem(MediaItem item) { boolean status = true; try { SolrMediaItem solrItem = new SolrMediaItem(item); server.addBean(solrItem, commitPeriod); // UpdateResponse response = server.commit(); // int statusId = response.getStatus(); // if (statusId == 0) { // status = true; // } } catch (Exception ex) { ex.printStackTrace(); Logger.getRootLogger().error(ex.getMessage()); status = false; } finally { return status; } }