List of usage examples for org.apache.solr.client.solrj SolrQuery SolrQuery
public SolrQuery(String q)
From source file:de.fhg.iais.cortex.search.DeleterImpl.java
License:Apache License
@Override public List<String> getDocumentIdsByProvider(String providerId) { try {/* www . j a va2 s . c o m*/ return getDocumentIds(new SolrQuery(SolrFields.PROVIDER_ID + ":" + providerId)); } catch (SolrServerException e) { throw new IndexerException("Could not get ids for provider " + providerId + ".", e); } }
From source file:de.fhg.iais.cortex.search.DeleterImpl.java
License:Apache License
@Override public List<String> deleteByIngestId(String providerId, String ingestId) { List<String> ids = null; try {//from w w w. jav a 2 s .com String deleteQuery = SolrFields.PROVIDER_ID + ":" + providerId + " AND " + SolrFields.INGEST_ID + ":" + ingestId; ids = getDocumentIds(new SolrQuery(deleteQuery)); this.solrMasterServer.deleteByQuery(deleteQuery); this.solrMasterServer.commit(); } catch (SolrServerException e) { throw new IndexerException("Could not delete for ingest " + ingestId + ".", e); } catch (IOException e) { throw new IndexerException("Could not delete for ingest " + ingestId + ".", e); } return ids; }
From source file:de.fhg.iais.cortex.search.DeleterImpl.java
License:Apache License
@Override public List<String> deleteByIngestId(String ingestId, boolean commit) { List<String> ids = null; try {// w w w. j a v a 2 s. c om String deleteQuery = SolrFields.INGEST_ID + ":" + ingestId; ids = getDocumentIds(new SolrQuery(deleteQuery)); this.solrMasterServer.deleteByQuery(deleteQuery); if (commit) { this.solrMasterServer.commit(); } } catch (SolrServerException e) { throw new IndexerException("Could not delete for ingest " + ingestId + ".", e); } catch (IOException e) { throw new IndexerException("Could not delete for ingest " + ingestId + ".", e); } return ids; }
From source file:de.fhg.iais.cortex.search.DeleterImpl.java
License:Apache License
@Override public List<String> deleteByProviderId(String id) { List<String> ids = null; try {//from w w w .j a va 2 s. c o m ids = getDocumentIds(new SolrQuery(SolrFields.PROVIDER_ID + ":" + id)); this.solrMasterServer.deleteByQuery(SolrFields.PROVIDER_ID + ":" + id); this.solrMasterServer.commit(); } catch (SolrServerException e) { throw new IndexerException("Could not delete for provider " + id + ".", e); } catch (IOException e) { throw new IndexerException("Could not delete for provider " + id + ".", e); } return ids; }
From source file:de.hebis.it.hds.gnd.out.AutorityRecordFileWriter.java
License:Open Source License
/** * Loop over all entries in the repository to write them to the output file *///from w w w . j av a2 s . co m private void listAllEntries() { String cursorMark = "*"; String nextCursorMark = null; QueryResponse rsp = null; SolrQuery query = new SolrQuery("id:*"); query.setRows(Integer.valueOf(config.getProperty("StepSizeForExport", "100"))); query.setSort(SortClause.asc("id")); do { // start with '*' in the first iteration, then use the last position if (nextCursorMark != null) { cursorMark = nextCursorMark; } // use the last position as new start value. query.set("cursorMark", new String[] { cursorMark }); if (LOG.isTraceEnabled()) { LOG.trace(query.toString()); } // execute the query try { rsp = server.query(query); if (rsp.getStatus() != 0) throw new SolrServerException("Responsestatus: " + rsp.getStatus()); } catch (SolrServerException | IOException e) { e.printStackTrace(); throw new RuntimeException("The index can't eval \"" + query.toString() + "\".", e); } nextCursorMark = rsp.getNextCursorMark(); // get the results of partial results List<AuthorityBean> partialResults = rsp.getBeans(AuthorityBean.class); if (LOG.isTraceEnabled()) LOG.trace(partialResults.size() + " records in this packet"); // loop over the results for (AuthorityBean entry : partialResults) { if (LOG.isTraceEnabled()) LOG.trace("Bearbeite: " + entry.id); printOut(entry); if ((maxCount != Integer.MAX_VALUE) && (count >= maxCount)) return; // optional exit for debug purposes } out.flush(); } while (!cursorMark.equals(nextCursorMark)); }
From source file:de.hybris.platform.solrfacetsearch.embedded.SolrFacetSearchEmbeddedTest.java
License:Open Source License
/** * *///from w w w . j a v a 2s. c o m @Test public void testEmbeddedInstance() throws Exception { try { // Get a server instance from the core container that matches the tenant id. for (int i = 0; i < 10; i++) { final SolrInputDocument document = new SolrInputDocument(); document.addField("id", "hello world test " + i, 1.0f); final String value = "hello world "; document.addField("shortDescription_text_de", value + i, 1.0f); document.addField("shortDescription_text_en", value + i, 1.0f); document.addField("shortDescription_text_fr", value + i, 1.0f); document.addField("longDescription_text_de", value + i, 1.0f); document.addField("longDescription_text_en", value + i, 1.0f); document.addField("longDescription_text_fr", value + i, 1.0f); server.add(document); } server.commit(); assertEquals(10, server.query(new SolrQuery("*:*")).getResults().size()); } catch (final Exception e) { server.rollback(); } }
From source file:de.hybris.platform.solrfacetsearch.integration.AbstractSolrIntegrationTest.java
License:Open Source License
/** * Method can be used to clear index for a given type, so that each test run has the same, 'clean' initial conditions * /*from www . j a va 2 s . c om*/ * @param solrConfig * @param typeCode * @throws SolrServerException * @throws IOException * @throws SolrServiceException */ protected void dropIndexForType(final SolrConfig solrConfig, final String typeCode) throws SolrServerException, IOException, SolrServiceException { final SolrServer solrServer = getSolrService().getSolrServerMaster(solrConfig, indexedType); assertNotNull(solrServer); solrServer.deleteByQuery(SOLR_QUERY_SELECT_ALL); solrServer.commit(); final SolrQuery query = new SolrQuery(SOLR_QUERY_SELECT_ALL); final QueryResponse response = solrServer.query(query); final int resultSize = response.getResults().size(); assertEquals("Result size", 0, resultSize); }
From source file:de.hybris.platform.solrfacetsearch.integration.AbstractSolrTest.java
License:Open Source License
/** * Drops the index content for the current {@link #indexedType} *//*from w w w .j a va 2 s .c o m*/ protected void dropIndex() throws SolrServiceException, SolrServerException, IOException { final SolrServer solrServer = getSolrService().getSolrServerMaster(solrConfig, indexedType); assertNotNull(solrServer); solrServer.deleteByQuery(SOLR_QUERY_SELECT_ALL); solrServer.commit(); final SolrQuery query = new SolrQuery(SOLR_QUERY_SELECT_ALL); final QueryResponse response = solrServer.query(query); final int resultSize = response.getResults().size(); assertEquals("Result size", 0, resultSize); }
From source file:de.hybris.platform.solrfacetsearch.integration.IndexFullProductTest.java
License:Open Source License
@Test public void verifySolrId() throws SolrServerException { final List<ProductModel> productModels = searchResult.getResult(); for (final ProductModel productModel : productModels) { final String solrDocId = prepareProductSolrId(productModel); final QueryResponse solrResponse = solrServer.query(new SolrQuery("id:\"" + solrDocId + "\"")); final SolrDocumentList solrDocumentList = solrResponse.getResults(); assertNotNull(solrDocumentList); assertEquals("Document with ID " + solrDocId + " is not found!", 1, solrDocumentList.size()); }//w w w. ja v a2 s. com }
From source file:de.hybris.platform.solrfacetsearch.integration.IndexFullProductTest.java
License:Open Source License
@Test public void verifyPK() throws SolrServerException { final List<ProductModel> productModels = searchResult.getResult(); for (final ProductModel productModel : productModels) { final long pk = productModel.getPk().getLongValue(); final QueryResponse solrResponse = solrServer.query(new SolrQuery("pk:\"" + pk + "\"")); final SolrDocumentList solrDocumentList = solrResponse.getResults(); assertNotNull(solrDocumentList); assertEquals("Document with PK " + pk + " is not found!", 1, solrDocumentList.size()); }//from w w w. j a va 2 s. c o m }