Changeset 6802 for SRUAggregator


Ignore:
Timestamp:
11/13/15 10:04:55 (9 years ago)
Author:
Leif-Jöran
Message:

Adding more silent corrections of non-quoted query strings. Adding positive and negative unit tests.

Location:
SRUAggregator/trunk/src
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Search.java

    r6395 r6802  
    4444        private final List<Result> results = Collections.synchronizedList(new ArrayList<Result>());
    4545        private final Statistics statistics;
    46         private final Pattern wsPattern = Pattern.compile("\\s");
     46        private static final Pattern quotePattern = Pattern.compile("[\\s<>=/\\(\\)]");
    4747
    4848        public Search(ThrottledClient searchClient,
     
    5454                this.version = version;
    5555                this.id = counter.getAndIncrement();
    56                 this.query = quoteIfMultiWordExpression(searchString);
     56                this.query = quoteIfQuotableExpression(searchString);
    5757                this.searchLanguage = searchLanguage;
    5858                this.statistics = statistics;
     
    177177        }
    178178
    179         private String quoteIfMultiWordExpression(String queryString) {
    180             Matcher matcher = wsPattern.matcher(queryString.trim());
    181             boolean wsFound = matcher.find();
    182             if (wsFound && !"\"".equals(queryString.charAt(0))) {
     179        protected static String quoteIfQuotableExpression(final String queryString) {
     180            Matcher matcher = quotePattern.matcher(queryString.trim());
     181            boolean quotableFound = matcher.find();
     182            if (quotableFound && !"\"".equals(queryString.charAt(0))) {
    183183                return "\"" + queryString + "\"";
    184184            }
Note: See TracChangeset for help on using the changeset viewer.