use of org.cytoscape.search.internal.util.CustomMultiFieldQueryParser in project cytoscape-impl by cytoscape.
the class IdentifiersCollector method search.
/**
* Searches for the given query string. By default (without specifying
* attributeName), search is carried out on all attribute fields. This
* functionality is enabled with the use of MultiFieldQueryParser.
*/
private void search(final String queryString, final AttributeFields attFields) throws IOException {
// Build a Query object.
// CustomMultiFieldQueryParser is used to support range queries on numerical attribute fields.
final CustomMultiFieldQueryParser queryParser = new CustomMultiFieldQueryParser(attFields, new StandardAnalyzer(Version.LUCENE_30, Collections.emptySet()));
try {
// Execute query
Query query = queryParser.parse(queryString);
hitCollector = new IdentifiersCollector(searcher);
searcher.search(query, hitCollector);
} catch (final ParseException pe) {
// Parse exceptions occur when colon appear in the query in an
// unexpected location, e.g. when attribute or value are
// missing in the query. In such case, the hitCollector
// variable will be null.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(null, pe.getMessage(), "Invalid query.", JOptionPane.ERROR_MESSAGE);
}
});
} catch (final Exception e) {
// Other types of exception may occur
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(null, e.getMessage(), "Query execution error.", JOptionPane.ERROR_MESSAGE);
}
});
}
}
Aggregations