Java Code Examples for org.apache.lucene.queryparser.flexible.standard.StandardQueryParser#setPointsConfigMap()
The following examples show how to use
org.apache.lucene.queryparser.flexible.standard.StandardQueryParser#setPointsConfigMap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LuceneStoreImpl.java From karaf-decanter with Apache License 2.0 | 5 votes |
@Override public void eviction() throws Exception { StandardQueryParser queryParser = new StandardQueryParser(); queryParser.setAllowLeadingWildcard(true); queryParser.setPointsConfigMap(points); Query query = queryParser.parse("alertUUID:* AND NOT alertRule:*", ""); indexWriter.deleteDocuments(query); indexWriter.commit(); }
Example 2
Source File: LuceneStoreImpl.java From karaf-decanter with Apache License 2.0 | 5 votes |
@Override public void delete(String queryString) throws Exception { StandardQueryParser queryParser = new StandardQueryParser(); queryParser.setAllowLeadingWildcard(true); queryParser.setPointsConfigMap(points); Query query = queryParser.parse(queryString, ""); indexWriter.deleteDocuments(query); indexWriter.commit(); }
Example 3
Source File: SearchImpl.java From lucene-solr with Apache License 2.0 | 4 votes |
private Query parseByStandardParser(String expression, String defField, Analyzer analyzer, QueryParserConfig config) { StandardQueryParser parser = new StandardQueryParser(analyzer); switch (config.getDefaultOperator()) { case OR: parser.setDefaultOperator(StandardQueryConfigHandler.Operator.OR); break; case AND: parser.setDefaultOperator(StandardQueryConfigHandler.Operator.AND); break; } parser.setEnablePositionIncrements(config.isEnablePositionIncrements()); parser.setAllowLeadingWildcard(config.isAllowLeadingWildcard()); parser.setDateResolution(config.getDateResolution()); parser.setFuzzyMinSim(config.getFuzzyMinSim()); parser.setFuzzyPrefixLength(config.getFuzzyPrefixLength()); parser.setLocale(config.getLocale()); parser.setTimeZone(config.getTimeZone()); parser.setPhraseSlop(config.getPhraseSlop()); if (config.getTypeMap() != null) { Map<String, PointsConfig> pointsConfigMap = new HashMap<>(); for (Map.Entry<String, Class<? extends Number>> entry : config.getTypeMap().entrySet()) { String field = entry.getKey(); Class<? extends Number> type = entry.getValue(); PointsConfig pc; if (type == Integer.class || type == Long.class) { pc = new PointsConfig(NumberFormat.getIntegerInstance(Locale.ROOT), type); } else if (type == Float.class || type == Double.class) { pc = new PointsConfig(NumberFormat.getNumberInstance(Locale.ROOT), type); } else { log.warn(String.format(Locale.ENGLISH, "Ignored invalid number type: %s.", type.getName())); continue; } pointsConfigMap.put(field, pc); } parser.setPointsConfigMap(pointsConfigMap); } try { return parser.parse(expression, defField); } catch (QueryNodeException e) { throw new LukeException(String.format(Locale.ENGLISH, "Failed to parse query expression: %s", expression), e); } }