Query q = QueryParsing.parseQuery(cmd.query, schema); long total = writer.deleteDocuments(subIndex, q, false); commit(subIndex, true);
/** * Helper utility for parsing a query using the Lucene QueryParser syntax. * @param qs query expression in standard Lucene syntax * @param schema used for default operator (overridden by params) and passed to the query parser for field format analysis information */ public static Query parseQuery(String qs, IndexSchema schema) { return parseQuery(qs, null, schema); }
/** * Executes a basic query in lucene syntax */ public static DocList doSimpleQuery(String sreq, SolrIndexSearcher searcher, IndexSchema schema, int start, int limit) throws IOException { List<String> commands = StrUtils.splitSmart(sreq,';'); String qs = commands.size() >= 1 ? commands.get(0) : ""; Query query = QueryParsing.parseQuery(qs, schema); // If the first non-query, non-filter command is a simple sort on an indexed field, then // we can use the Lucene sort ability. Sort sort = null; if (commands.size() >= 2) { sort = QueryParsing.parseSort(commands.get(1), schema); } DocList results = searcher.getDocList(query,(DocSet)null, sort, start, limit); return results; }
boolean delAll=false; try { Query q = QueryParsing.parseQuery(cmd.query, schema); delAll = MatchAllDocsQuery.class == q.getClass();
public void deleteByQuery(DeleteUpdateCommand cmd) throws IOException { if (!cmd.fromPending && !cmd.fromCommitted) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"meaningless command: " + cmd); if (!cmd.fromPending || !cmd.fromCommitted) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"operation not supported: " + cmd); Query q = QueryParsing.parseQuery(cmd.query, schema); int totDeleted = 0; synchronized(this) { closeWriter(); openSearcher(); // if we want to count the number of docs that were deleted, then // we need a new instance of the DeleteHitCollector final DeleteHitCollector deleter = new DeleteHitCollector(searcher); searcher.search(q, null, deleter); totDeleted = deleter.deleted; } if (core.log.isDebugEnabled()) { core.log.debug(core.getLogId()+"docs deleted:" + totDeleted); } }
query = QueryParsing.parseQuery(qs, req.getSchema());
int matchOffset = params.getInt( MoreLikeThisParams.MATCH_OFFSET, 0 ); Query query = QueryParsing.parseQuery(q, params.get(CommonParams.DF), params, req.getSchema()); DocList match = searcher.getDocList(query, null, null, matchOffset, 1, flags ); // only get the first one... if( includeMatch ) {
Query query = QueryParsing.parseQuery(qs, req.getSchema());