Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when percolating a document that contains a completion field #4028

Closed
javanna opened this issue Oct 31, 2013 · 0 comments · Fixed by #4129
Closed

NPE when percolating a document that contains a completion field #4028

javanna opened this issue Oct 31, 2013 · 0 comments · Fixed by #4129

Comments

@javanna
Copy link
Member

javanna commented Oct 31, 2013

Although it might not make much sense to percolate a document containing a completion field, that's what you end up doing if you percolate while indexing, and your mapping contains a completion field. When adding the completion field to the memory index a NullPointerException is thrown.

This happens with the 0.90 branch. Happens also with master, at least percolating an existing document.

Here is the recreation:

curl -XPUT localhost:9200/hotels -d '
{
  "mappings": {
    "hotel" : {
      "properties" : {
        "name" : { "type" : "string" },
        "city" : { "type" : "string" },
        "name_suggest" : {
          "type" :     "completion"
        }
      }
    }
  }
}'

curl -XGET localhost:9200/hotels/hotel/_percolate -d '{
    "doc" : {
        "name" :         "Mercure Hotel Munich",
        "city" :         "Munich",
        "name_suggest" : "Mercure Hotel Munich"
    }
}
'

Here is the stacktrace:

java.lang.RuntimeException: java.lang.NullPointerException
    at org.apache.lucene.index.memory.MemoryIndex.addField(MemoryIndex.java:463)
    at org.apache.lucene.index.memory.MemoryIndex.addField(MemoryIndex.java:370)
    at org.elasticsearch.index.percolator.PercolatorExecutor.percolate(PercolatorExecutor.java:450)
    at org.elasticsearch.index.percolator.PercolatorExecutor.percolate(PercolatorExecutor.java:422)
    at org.elasticsearch.index.percolator.PercolatorService.percolate(PercolatorService.java:111)
    at org.elasticsearch.action.percolate.TransportPercolateAction.shardOperation(TransportPercolateAction.java:93)
    at org.elasticsearch.action.percolate.TransportPercolateAction.shardOperation(TransportPercolateAction.java:41)
    at org.elasticsearch.action.support.single.custom.TransportSingleCustomOperationAction$AsyncSingleAction$2.run(TransportSingleCustomOperationAction.java:175)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NullPointerException
    at org.apache.lucene.util.BytesRefHash.add(BytesRefHash.java:274)
    at org.apache.lucene.index.memory.MemoryIndex.addField(MemoryIndex.java:437)
    ... 10 more
@ghost ghost assigned spinscale and martijnvg Oct 31, 2013
martijnvg added a commit to martijnvg/elasticsearch that referenced this issue Nov 8, 2013
The CompletionTokenStream doesn't properly forward the call to its attributes, so when the percolator needs to access terms of this stream, null was returned and this isn't expected in the MemoryIndex.

Closes elastic#4028
s1monw added a commit that referenced this issue Nov 10, 2013
This adds a delegate to CharTermAttributeImpl to be compatible
with the Percolator that needs a CharTermAttribute. Yet compared
to CharTermAttributImpl we only fill the BytesRef with UTF-8 since
we already have it and only if we need to convert to UTF-16 we do it.

Closes #4028
@s1monw s1monw closed this as completed in 77239a7 Nov 10, 2013
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
This adds a delegate to CharTermAttributeImpl to be compatible
with the Percolator that needs a CharTermAttribute. Yet compared
to CharTermAttributImpl we only fill the BytesRef with UTF-8 since
we already have it and only if we need to convert to UTF-16 we do it.

Closes elastic#4028
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants