Created
June 15, 2011 09:46
-
-
Save melix/1026809 to your computer and use it in GitHub Desktop.
Throws a parse error when query gets executed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.elasticsearch.action.search.SearchResponse; | |
import org.elasticsearch.client.Client; | |
import org.elasticsearch.client.action.search.SearchRequestBuilder; | |
import org.elasticsearch.index.query.xcontent.SpanOrQueryBuilder; | |
import org.elasticsearch.index.query.xcontent.SpanTermQueryBuilder; | |
import org.elasticsearch.node.Node; | |
import org.elasticsearch.node.NodeBuilder; | |
import static org.elasticsearch.node.NodeBuilder.nodeBuilder; | |
public class SpanOrPb { | |
public static void main(String[] args) throws InterruptedException { | |
final NodeBuilder nodeBuilder = nodeBuilder(); | |
nodeBuilder.settings().put("path.data", "/home/cedric/NOTYET-SVN/LEA-ELASTICSEARCH/leastic/data"); | |
Node node = nodeBuilder.local(true).node(); | |
Client client = node.client(); | |
// Wait 2 seconds to get nodes ready | |
Thread.sleep(2000); | |
// Now run a query | |
SpanOrQueryBuilder soqb = new SpanOrQueryBuilder(); | |
soqb.clause( | |
new SpanTermQueryBuilder("title", "java").boost(1.0f) | |
); | |
soqb.clause( | |
new SpanTermQueryBuilder("title", "javas").boost(1.0f) | |
); | |
final SearchRequestBuilder builder = client.prepareSearch().setQuery(soqb); | |
builder.setIndices("leastic"); | |
builder.setTypes("resume"); | |
builder.addField("vid"); | |
builder.addField("title"); | |
final SearchResponse response = builder.execute().actionGet(); | |
// Throws : | |
// Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query], total failure; shardFailures {[1][leastic][3]: SearchParseException[[leastic][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [_na_]]]; nested: QueryParsingException[[leastic] spanOr must include [clauses]]; }{[1][leastic][0]: SearchParseException[[leastic][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [_na_]]]; nested: QueryParsingException[[leastic] spanOr must include [clauses]]; }{[1][leastic][1]: SearchParseException[[leastic][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [_na_]]]; nested: QueryParsingException[[leastic] spanOr must include [clauses]]; }{[1][leastic][2]: SearchParseException[[leastic][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [_na_]]]; nested: QueryParsingException[[leastic] spanOr must include [clauses]]; } | |
// at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:248) | |
// at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$400(TransportSearchTypeAction.java:75) | |
// at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:198) | |
// at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:137) | |
// at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:76) | |
// at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192) | |
// at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$000(TransportSearchTypeAction.java:75) | |
// at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:169) | |
// at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) | |
// at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) | |
// at java.lang.Thread.run(Thread.java:662) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment