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;
|
package com.google.gerrit.server.index;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Splitter;
|
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.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
@@ -232,7 +235,15 @@ public class ChangeField {
|
|||||||
@Override
|
@Override
|
||||||
public Iterable<String> get(ChangeData input, FillArgs args)
|
public Iterable<String> get(ChangeData input, FillArgs args)
|
||||||
throws OrmException {
|
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> {
|
class HashtagPredicate extends IndexPredicate<ChangeData> {
|
||||||
HashtagPredicate(String hashtag) {
|
HashtagPredicate(String hashtag) {
|
||||||
super(ChangeField.HASHTAG, hashtag);
|
super(ChangeField.HASHTAG, hashtag.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(final ChangeData object) throws OrmException {
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user