Make Lucene case insensitive when searching for hashtags
The Hashtags will still be stored as case sensitive. A future HashtagValidator/HashtagTransformer @Extensionpoint could allow users to finetune how the hashtags are stored and accepted. Change-Id: Ibb6d6343a228fcafb6f482597655281792f85a62
This commit is contained in:
@@ -14,8 +14,11 @@
|
||||
|
||||
package com.google.gerrit.server.index;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -232,7 +235,15 @@ public class ChangeField {
|
||||
@Override
|
||||
public Iterable<String> get(ChangeData input, FillArgs args)
|
||||
throws OrmException {
|
||||
return input.notes().load().getHashtags();
|
||||
return ImmutableSet.copyOf(Iterables.transform(input.notes().load()
|
||||
.getHashtags(), new Function<String, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(String input) {
|
||||
return input.toLowerCase();
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -20,12 +20,17 @@ import com.google.gwtorm.server.OrmException;
|
||||
|
||||
class HashtagPredicate extends IndexPredicate<ChangeData> {
|
||||
HashtagPredicate(String hashtag) {
|
||||
super(ChangeField.HASHTAG, hashtag);
|
||||
super(ChangeField.HASHTAG, hashtag.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(final ChangeData object) throws OrmException {
|
||||
return object.notes().load().getHashtags().contains(getValue());
|
||||
for (String hashtag : object.notes().load().getHashtags()) {
|
||||
if (hashtag.equalsIgnoreCase(getValue())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user