Skip to content

Commit

Permalink
Upgrade to Elasticsearch 1.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Jochen Schalanda committed Mar 11, 2015
1 parent 954254d commit 28094cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 34 deletions.
4 changes: 0 additions & 4 deletions graylog2-server/pom.xml
Expand Up @@ -237,10 +237,6 @@
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
</dependency>

<dependency>
<groupId>org.kie</groupId>
Expand Down
Expand Up @@ -18,12 +18,11 @@

import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.queryparser.classic.Token;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.search.SearchParseException;
import org.glassfish.jersey.server.ChunkedOutput;
import org.graylog2.indexer.InvalidRangeFormatException;
import org.graylog2.indexer.results.ScrollResult;
Expand Down Expand Up @@ -177,23 +176,22 @@ protected Sorting buildSorting(String sort) {

protected BadRequestException createRequestExceptionForParseFailure(String query, SearchPhaseExecutionException e) {
LOG.warn("Unable to execute search: {}", e.getMessage());
QueryParseError errorMessage = QueryParseError.create(query, e.getMessage(), e.getClass().getCanonicalName());

// we won't actually iterate over all of the shard failures, only the first one,
// since we assume that parse errors happen on all of the shards.
for (ShardSearchFailure failure : e.shardFailures()) {
//noinspection ThrowableResultOfMethodCallIgnored
Throwable unwrapped = ExceptionsHelper.unwrapCause(failure.failure());
if (!(unwrapped instanceof SearchParseException)) {
LOG.warn("Unhandled ShardSearchFailure", e);
return new BadRequestException();
}
Throwable rootCause = ((SearchParseException) unwrapped).getRootCause();
if (rootCause instanceof ParseException) {
Token currentToken = ((ParseException) rootCause).currentToken;

QueryParseError errorMessage = QueryParseError.create(query, "Unable to execute search", e.getClass().getCanonicalName());

// We're so going to hell for this…
if(e.getMessage().contains("nested: ParseException")) {
final QueryParser queryParser = new QueryParser("", new StandardAnalyzer());
try {
queryParser.parse(query);
} catch (ParseException parseException) {
Token currentToken = parseException.currentToken;
if (currentToken == null) {
LOG.warn("No position/token available for ParseException.", rootCause);
errorMessage = QueryParseError.create(query, rootCause.getMessage(), rootCause.getClass().getCanonicalName());
LOG.warn("No position/token available for ParseException.", parseException);
errorMessage = QueryParseError.create(
query,
parseException.getMessage(),
parseException.getClass().getCanonicalName());
} else {
// scan for first usable token with position information
int beginColumn = 0;
Expand All @@ -214,12 +212,9 @@ protected BadRequestException createRequestExceptionForParseFailure(String query
beginLine,
endColumn,
endLine,
rootCause.getMessage(),
rootCause.getClass().getCanonicalName());
parseException.getMessage(),
parseException.getClass().getCanonicalName());
}
} else {
LOG.debug("Root cause of SearchParseException has unexpected, generic type: " + rootCause.getClass(), rootCause);
errorMessage = QueryParseError.create(query, rootCause.getMessage(), rootCause.getClass().getCanonicalName());
}
}

Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Expand Up @@ -220,12 +220,7 @@
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.3.7</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>4.9.1</version>
<version>1.4.4</version>
</dependency>

<dependency>
Expand Down

0 comments on commit 28094cb

Please sign in to comment.