refactoring

This commit is contained in:
Shinsuke Sugaya 2016-01-28 17:29:10 +09:00
parent 34863fc132
commit a72c21c776
6 changed files with 24 additions and 23 deletions

View file

@ -53,10 +53,6 @@ public class BadWordService implements Serializable {
@Resource
protected BadWordBhv badWordBhv;
public BadWordService() {
super();
}
public List<BadWord> getBadWordList(final BadWordPager badWordPager) {
final PagingResultBean<BadWord> badWordList = badWordBhv.selectPage(cb -> {

View file

@ -195,7 +195,7 @@ public class KuromojiItem extends DictionaryItem {
result = result.replace("\"", "\"\"");
}
if (result.indexOf(',') >= 0) {
result = "\"" + result + "\"";
return "\"" + result + "\"";
}
return result;
}

View file

@ -142,7 +142,9 @@ public abstract class AbstractDataStoreImpl implements DataStore {
protected void sleep(final long interval) {
try {
Thread.sleep(interval);
} catch (final Exception e) {}
} catch (final Exception e) {
// ignore
}
}
protected abstract void storeData(DataConfig dataConfig, IndexUpdateCallback callback, Map<String, String> paramMap,

View file

@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
@ -119,7 +120,7 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl {
}
protected boolean isCsvFile(final File parentFile, final String filename) {
final String name = filename.toLowerCase();
final String name = filename.toLowerCase(Locale.ROOT);
for (final String suffix : csvFileSuffixs) {
if (name.endsWith(suffix)) {
return true;

View file

@ -24,9 +24,6 @@ public class FacetInfo {
//@Maxbytelength(maxbytelength = 255)
public String[] query;
//@Maxbytelength(maxbytelength = 1000)
public String prefix;
//@IntegerType
public String limit;
@ -41,7 +38,7 @@ public class FacetInfo {
@Override
public String toString() {
return "FacetInfo [field=" + Arrays.toString(field) + ", q=" + Arrays.toString(query) + ", prefix=" + prefix + ", limit=" + limit
+ ", minCount=" + minCount + ", sort=" + sort + ", missing=" + missing + "]";
return "FacetInfo [field=" + Arrays.toString(field) + ", q=" + Arrays.toString(query) + ", limit=" + limit + ", minCount="
+ minCount + ", sort=" + sort + ", missing=" + missing + "]";
}
}

View file

@ -159,6 +159,7 @@ import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order;
import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
import org.elasticsearch.threadpool.ThreadPool;
import org.slf4j.Logger;
@ -410,13 +411,13 @@ public class FessEsClient implements Client {
}
}
} catch (final Exception e) {
logger.warn("Failed to parse " + dataPath.toString());
logger.warn("Failed to parse " + dataPath);
}
return StringUtil.EMPTY;
});
final BulkResponse response = builder.execute().actionGet();
if (response.hasFailures()) {
logger.warn("Failed to register " + dataPath.toString() + ": " + response.buildFailureMessage());
logger.warn("Failed to register " + dataPath + ": " + response.buildFailureMessage());
}
} catch (final Exception e) {
logger.warn("Failed to create " + configIndex + "/" + configType + " mapping.");
@ -505,7 +506,7 @@ public class FessEsClient implements Client {
}
final long execTime = System.currentTimeMillis() - startTime;
return searchResult.build(requestBuilder, execTime, OptionalEntity.ofNullable(response, () -> {/* TODO */}));
return searchResult.build(requestBuilder, execTime, OptionalEntity.ofNullable(response, () -> {}));
}
public <T> T search(final String index, final String type, final SearchCondition<SearchRequestBuilder> condition,
@ -538,7 +539,7 @@ public class FessEsClient implements Client {
}
final long execTime = System.currentTimeMillis() - startTime;
return searchResult.build(searchRequestBuilder, execTime, OptionalEntity.ofNullable(searchResponse, () -> {/* TODO */}));
return searchResult.build(searchRequestBuilder, execTime, OptionalEntity.ofNullable(searchResponse, () -> {}));
}
public OptionalEntity<Map<String, Object>> getDocument(final String index, final String type,
@ -830,11 +831,20 @@ public class FessEsClient implements Client {
if (queryHelper.isFacetField(f)) {
final String encodedField = BaseEncoding.base64().encode(f.getBytes(StandardCharsets.UTF_8));
final TermsBuilder termsBuilder = AggregationBuilders.terms(Constants.FACET_FIELD_PREFIX + encodedField).field(f);
// TODO order
if ("term".equals(facetInfo.sort)) {
termsBuilder.order(Order.term(true));
} else if ("count".equals(facetInfo.sort)) {
termsBuilder.order(Order.count(true));
}
if (facetInfo.limit != null) {
// TODO
termsBuilder.size(Integer.parseInt(facetInfo.limit));
}
if (facetInfo.minCount != null) {
termsBuilder.minDocCount(Long.parseLong(facetInfo.minCount));
}
if (facetInfo.missing != null) {
termsBuilder.missing(facetInfo.missing);
}
searchRequestBuilder.addAggregation(termsBuilder);
} else {
throw new SearchQueryException("Invalid facet field: " + f);
@ -848,11 +858,6 @@ public class FessEsClient implements Client {
final FilterAggregationBuilder filterBuilder =
AggregationBuilders.filter(Constants.FACET_QUERY_PREFIX + encodedFacetQuery).filter(
facetContext.getQueryBuilder());
// TODO order
if (facetInfo.limit != null) {
// TODO
// filterBuilder.size(Integer.parseInt(facetInfo .limit));
}
searchRequestBuilder.addAggregation(filterBuilder);
});
}