Xiaojian Zhou created GEODE-9015:
------------------------------------

             Summary: Lucene query on nest object's array item hit NPE
                 Key: GEODE-9015
                 URL: https://issues.apache.org/jira/browse/GEODE-9015
             Project: Geode
          Issue Type: Bug
            Reporter: Xiaojian Zhou


create lucene index --name=arrayIndex --region=/exampleRegion 
--field=exampleIdentifier.systemIds[0].system --analyzer=DEFAULT 
--serializer=org.apache.geode.cache.lucene.FlatFormatSerializer

create region --name=exampleRegion --type=PARTITION

put --region=/exampleRegion --key="('id':'1')" --value="('exampleIdentifier': 
{'exampleId': '000000000','systemIds':[{'id': 'ID','system': 'MUREX'}]})"

put --region=/exampleRegion --key="('id':'2')" --value="('exampleIdentifier': 
{'exampleId': '000000001','systemIds':[{'id': 'ID','system': 'MUREX'}, {'id': 
'ID1','system': 'WHITEBOX'}]})"

search lucene --name=arrayIndex --region=/exampleRegion 
--queryString="exampleIdentifier.systemIds[0].system:MUREX" 
--defaultField="exampleIdentifier.systemIds[0].system"

gfsh>search lucene --name=arrayIndex --region=/exampleRegion 
--queryString="exampleIdentifier.systemIds[0].system:MUREX" 
--defaultField="exampleIdentifier.systemIds[0].system"
Error while processing command <search lucene --name=arrayIndex 
--region=/exampleRegion 
--queryString="exampleIdentifier.systemIds[0].system:MUREX" 
--defaultField="exampleIdentifier.systemIds[0].system"> Reason : class 
java.lang.NullPointerException cannot be cast to class java.util.Set 
(java.lang.NullPointerException and java.util.Set are in module java.base of 
loader 'bootstrap')

This is due to user used wrong syntax in creating index and query. 

It is not supposed to use array item as field name. We should use array's name 
here. 

The correct syntax is:

gfsh>create lucene index --name=arrayIndex --region=/exampleRegion 
--field=exampleIdentifier.systemIds.system --analyzer=DEFAULT 
--serializer=org.apache.geode.cache.lucene.FlatFormatSerializer

gfsh>search lucene --name=arrayIndex --region=/exampleRegion 
--queryString="exampleIdentifier.systemIds.system:MUREX" 
--defaultField="exampleIdentifier.systemIds.system"

However, our code should report better error message instead of throwing NPE. 

see GEODE-9013 for detail use case example. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to