Problem with Or filter


(rs1050) #1

I am getting this exception

Dec 06 20:35:56,30 [31223651@qtp-32715418-11] ERROR org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs], total failure; shardFailures {null: RemoteTransportException[[Multiple Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested: ArrayIndexOutOfBoundsException[216]; }{null: RemoteTransportException[[Multiple Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested: ArrayIndexOutOfBoundsException[216]; }{null: RemoteTransportException[[Multiple Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested: ArrayIndexOutOfBoundsException[216]; }{null: RemoteTransportException[[Multiple Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested: ArrayIndexOutOfBoundsException[216]; }{null: RemoteTransportException[[Multiple Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested: ArrayIndexOutOfBoundsException[216]; }

when using simple Or filter.

Thank you.
RS


(rs1050) #2

FYI I think this happens when one of the fields (both numeric) on which I had 'or' filter had null as value.

Does not hurt me anymore, but please change exception to save time for others.

Thank you.
RS.


(Shay Banon) #3

Can you gist a recreation?
On Tuesday, December 7, 2010 at 3:38 AM, rs1050 wrote:

I am getting this exception

Dec 06 20:35:56,30 [31223651@qtp-32715418-11] ERROR
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to
execute phase [dfs], total failure; shardFailures {null:
RemoteTransportException[[Multiple
Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested:
ArrayIndexOutOfBoundsException[216]; }{null:
RemoteTransportException[[Multiple
Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested:
ArrayIndexOutOfBoundsException[216]; }{null:
RemoteTransportException[[Multiple
Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested:
ArrayIndexOutOfBoundsException[216]; }{null:
RemoteTransportException[[Multiple
Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested:
ArrayIndexOutOfBoundsException[216]; }{null:
RemoteTransportException[[Multiple
Man][inet[/192.168.1.108:9300]][search/phase/dfs]]; nested:
ArrayIndexOutOfBoundsException[216]; }

when using simple Or filter.

Thank you.
RS

--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Problem-with-Or-filter-tp2031072p2031072.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(rs1050) #4

Here is the code I had:
XContentFilterBuilder filterBuilder = andFilter(termFilter(JOB_FLD_COUNTRY_CODE, user.jobCountryCode1));

    NumericRangeFilterBuilder hourlyFilter = null;
    NumericRangeFilterBuilder totalFilter = null;

        hourlyFilter = numericRangeFilter(FIELD_B).gte(123)
        totalFilter = numericRangeFilter(FIELD_A).gte(432)

        filterBuilder.add(
                orFilter(
                        totalFilter,
                        hourlyFilter
                )
        );

When I was indexing the object, one of the values for FIELD_A or FIELD_B was null and then I got the exception. When I changed indexing piece to put zero if the field is null everything works.

I am using 0.13.1

Thank you.
RS


(Shay Banon) #5

Can you gist a curl recreation? One that index some data, and then issue the mentioned queries?
On Tuesday, December 7, 2010 at 11:56 PM, rs1050 wrote:

Here is the code I had:
XContentFilterBuilder filterBuilder =
andFilter(termFilter(JOB_FLD_COUNTRY_CODE, user.jobCountryCode1));

NumericRangeFilterBuilder hourlyFilter = null;
NumericRangeFilterBuilder totalFilter = null;

hourlyFilter = numericRangeFilter(FIELD_B).gte(123)
totalFilter = numericRangeFilter(FIELD_A).gte(432)

filterBuilder.add(
orFilter(
totalFilter,
hourlyFilter
)
);

When I was indexing the object, one of the values for FIELD_A or FIELD_B was
null and then I got the exception. When I changed indexing piece to put zero
if the field is null everything works.

I am using 0.13.1

Thank you.
RS

View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Problem-with-Or-filter-tp2031072p2036478.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(rs1050) #6

The index was created like this:

curl -XPUT 'http://localhost:9200/jobs'

The data was put via grails via java api, here is code I used:

    def builder = jsonBuilder().startObject();
                    .field(FIELD_A, job.maxHourlyComp)
                    .field(FIELD_B, job.maxTotalComp)

when I changed the code to this it works correctly

    def builder = jsonBuilder().startObject();
                    .field(FIELD_A, job.maxHourlyComp ?: AppConstants.ZERO)
                    .field(FIELD_B, job.maxTotalComp ?: AppConstants.ZERO)

where constant is defined as this:
public static final double ZERO = 0.0;


(Shay Banon) #7

Can you send a curl recreation? When curl requests to index the data, and then the curl request that does the search? It will simplify things on my end.
On Wednesday, December 8, 2010 at 1:29 AM, rs1050 wrote:

The index was created like this:

curl -XPUT 'http://localhost:9200/jobs'

The data was put via grails via java api, here is code I used:

def builder = jsonBuilder().startObject();
.field(FIELD_A, job.maxHourlyComp)
.field(FIELD_B, job.maxTotalComp)

when I changed the code to this it works correctly

def builder = jsonBuilder().startObject();
.field(FIELD_A, job.maxHourlyComp ?:
AppConstants.ZERO)
.field(FIELD_B, job.maxTotalComp ?:
AppConstants.ZERO)

where constant is defined as this:
public static final double ZERO = 0.0;

--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Problem-with-Or-filter-tp2031072p2036979.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(rs1050) #8

I am having problems running the simple search via curl for some reason (0.13.1)

curl -XPUT 'http://localhost:9200/rs1050/'
curl -XPUT 'http://localhost:9200/rs1050/jobs/1' -d '
{
"user" : "rs1050",
"fieldA" : null,
"fieldB" : null
}
'
then I use basic search like this
curl -XGET 'http://localhost:9200/rs1050/jobs/_search' -d '
{
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}
'

and I am getting this exception

org.elasticsearch.search.SearchParseException: [rs1050][4]: from[-1],size[-1]: Parse Failure [Failed to parse [
{
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}
]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:420)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:335)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:169)
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:131)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.j
ava: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$1.run(TransportSearchTypeAction.java:150)
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)
Caused by: org.elasticsearch.search.SearchParseException: [rs1050][4]: from[-1],size[-1]: Parse Failure [No parser for element [filtered]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:405)
... 10 more


(Shay Banon) #9

You need to wrap it in another query :), since the search body can have many more parameters, it needs to know what the main query is. Here is how it should look like: https://gist.github.com/732957.
On Wednesday, December 8, 2010 at 1:58 AM, rs1050 wrote:

I am having problems running the simple search via curl for some reason
(0.13.1)

curl -XPUT 'http://localhost:9200/rs1050/'
curl -XPUT 'http://localhost:9200/rs1050/jobs/1' -d '
{
"user" : "rs1050",
"fieldA" : null,
"fieldB" : null
}
'
then I use basic search like this
curl -XGET 'http://localhost:9200/rs1050/jobs/_search' -d '
{
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}
'

and I am getting this exception

org.elasticsearch.search.SearchParseException: [rs1050][4]:
from[-1],size[-1]: Parse Failure [Failed to parse [
{
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}
]]
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:420)
at
org.elasticsearch.search.SearchService.createContext(SearchService.java:335)
at
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:169)
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:131)
at
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.j
ava: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$1.run(TransportSearchTypeAction.java:150)
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)
Caused by: org.elasticsearch.search.SearchParseException: [rs1050][4]:
from[-1],size[-1]: Parse Failure [No parser for element [filtered]]
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:405)
... 10 more

View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Problem-with-Or-filter-tp2031072p2037073.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(system) #10