Lucene style range query string throws an error


(mr ow bot) #1

Hi,

I'm new to elastic search, are lucene style query strings supposed to
work?

I'm executing queries in Java like this:

client.prepareSearch(indexName).setQuery(queryString(searchString)).execute().actionGet().hits();

the JSON is indexed like this:

client.prepareIndex().setContentType(XContentType.JSON).setIndex(indexName).setId(id).setType(type).setSource(jsonString).execute().actionGet();

and the json objects I am indexing look like this:

{
"key" : "kiwi",
"maximum" : 2500000,
"alertLevel" : 80.0,
"amountTaken" : 64550,
"amountTakenPercent" : 2.58200,
"auditLogEntries" : [ {
"auditInfo" : {
"user" : "mr ow bot",
"tool" : "xxx",
"updateTime" : "2010-12-15T15:41:04.112+08:00"
},
"operation" : "CREATE_RESERVATION",
"parameters" : [ "id1", "64550" ]
} ],
"currentReservationAmountsById" : {
"id1" : 64550
},
"oldReservationAmountsById" : {
}
}

The search string "alertLevel:80.0" works and returns results but
"alertLevel:[70.0 to 90.0]" doesn't and actually throws:

Caused by:
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed
to execute phase [query], total failure; shardFailures {null:
ArrayIndexOutOfBoundsException[68]}{null:
ArrayIndexOutOfBoundsException[68]}{null:
ArrayIndexOutOfBoundsException[68]}{null:
ArrayIndexOutOfBoundsException[68]}{null:
ArrayIndexOutOfBoundsException[68]}
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:
251)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction.access$200(TransportSearchTypeAction.java:77)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:197)
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:
134)
at
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction
$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:
76)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction.access$000(TransportSearchTypeAction.java:77)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction$2.run(TransportSearchTypeAction.java:168)
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:619)

Am I doing it wrong? Is there a way to do range based queries using
query strings (it's just a big search box on the front end, so query
strings are preferable)?

Cheers,

Mike.


(Shay Banon) #2

try and do [70 TO 90] (uppercase TO).

On Wed, Dec 15, 2010 at 9:48 AM, mr ow bot mike.rowbotham@gmail.com wrote:

Hi,

I'm new to elastic search, are lucene style query strings supposed to
work?

I'm executing queries in Java like this:

client.prepareSearch(indexName).setQuery(queryString(searchString)).execute().actionGet().hits();

the JSON is indexed like this:

client.prepareIndex().setContentType(XContentType.JSON).setIndex(indexName).setId(id).setType(type).setSource(jsonString).execute().actionGet();

and the json objects I am indexing look like this:

{
"key" : "kiwi",
"maximum" : 2500000,
"alertLevel" : 80.0,
"amountTaken" : 64550,
"amountTakenPercent" : 2.58200,
"auditLogEntries" : [ {
"auditInfo" : {
"user" : "mr ow bot",
"tool" : "xxx",
"updateTime" : "2010-12-15T15:41:04.112+08:00"
},
"operation" : "CREATE_RESERVATION",
"parameters" : [ "id1", "64550" ]
} ],
"currentReservationAmountsById" : {
"id1" : 64550
},
"oldReservationAmountsById" : {
}
}

The search string "alertLevel:80.0" works and returns results but
"alertLevel:[70.0 to 90.0]" doesn't and actually throws:

Caused by:
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed
to execute phase [query], total failure; shardFailures {null:
ArrayIndexOutOfBoundsException[68]}{null:
ArrayIndexOutOfBoundsException[68]}{null:
ArrayIndexOutOfBoundsException[68]}{null:
ArrayIndexOutOfBoundsException[68]}{null:
ArrayIndexOutOfBoundsException[68]}
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:
251)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction.access$200(TransportSearchTypeAction.java:77)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:197)
at

org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:
134)
at
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction

$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:
76)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction.access$000(TransportSearchTypeAction.java:77)
at org.elasticsearch.action.search.type.TransportSearchTypeAction
$BaseAsyncAction$2.run(TransportSearchTypeAction.java:168)
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:619)

Am I doing it wrong? Is there a way to do range based queries using
query strings (it's just a big search box on the front end, so query
strings are preferable)?

Cheers,

Mike.


(system) #3