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 with Fuzzy Like This on non existing field #2690

Closed
dadoonet opened this issue Feb 25, 2013 · 3 comments
Closed

NPE with Fuzzy Like This on non existing field #2690

dadoonet opened this issue Feb 25, 2013 · 3 comments
Assignees

Comments

@dadoonet
Copy link
Member

Consider the following curl recreation:

curl -XDELETE http://localhost:9200/npefuzzy

curl -XPUT http://localhost:9200/npefuzzy?pretty -d '{
  "settings" : { "index" : { "number_of_shards" : 1, "number_of_replicas" : 0 }}
}'

curl -XPUT http://localhost:9200/npefuzzy/beer/1?pretty -d '{
   "brand":"Grimbergen",
   "colour":"PALE",
   "size":1.3476184461445255,
   "price":7.318647685097387,
   "date":1320090719440
}'

curl -XPOST "localhost:9200/npefuzzy/_refresh?pretty"

# This one is OK
curl -XPOST http://localhost:9200/npefuzzy/beer/_search?pretty -d '
{"query":{
  "flt" : {
    "fields" : [ "brand", "colour" ],
    "like_text" : "heineken is a pale beer",
    "max_query_terms" : 12
  }
}}'

# This one was ok (no error) in 0.20 (Lucene 3) but fails with 0.21 (Lucene 4)
curl -XPOST http://localhost:9200/npefuzzy/beer/_search?pretty -d '
{"query":{
  "flt" : {
    "fields" : [ "brand", "nonexistingfield" ],
    "like_text" : "heineken is a pale beer",
    "max_query_terms" : 12
  }
}}'

In 0.20.x (Lucene 3), we get no result:

{
 "took": 5,
 "timed_out": false,
 "_shards": {
  "total": 1,
  "successful": 1,
  "failed": 0
 },
 "hits": {
  "total": 0,
  "max_score": null,
  "hits": []
 }
}

With 0.21 (Lucene 4):

{
  "error" : "SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {[5d_VkN-ARky1L_LUVoKJEQ][npefuzzy][0]: QueryPhaseExecutionException[[npefuzzy][0]: query[filtered(null)->cache(_type:beer)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: NullPointerException; }]",
  "status" : 500
}

Logs are:

[2013-02-25 21:10:21,141][DEBUG][action.search.type       ] [Umar] [npefuzzy][0], node[5d_VkN-ARky1L_LUVoKJEQ], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@313e36eb]
org.elasticsearch.search.query.QueryPhaseExecutionException: [npefuzzy][0]: query[filtered(null)->cache(_type:beer)],from[0],size[10]: Query Failed [Failed to execute main query]
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:139)
    at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:316)
    at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:243)
    at org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:75)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)
    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:680)
Caused by: java.lang.NullPointerException
    at org.apache.lucene.sandbox.queries.SlowFuzzyTermsEnum$LinearFuzzyTermsEnum.<init>(SlowFuzzyTermsEnum.java:89)
    at org.apache.lucene.sandbox.queries.SlowFuzzyTermsEnum.maxEditDistanceChanged(SlowFuzzyTermsEnum.java:58)
    at org.apache.lucene.search.FuzzyTermsEnum.bottomChanged(FuzzyTermsEnum.java:211)
    at org.apache.lucene.search.FuzzyTermsEnum.<init>(FuzzyTermsEnum.java:144)
    at org.apache.lucene.sandbox.queries.SlowFuzzyTermsEnum.<init>(SlowFuzzyTermsEnum.java:48)
    at org.apache.lucene.sandbox.queries.FuzzyLikeThisQuery.addTerms(FuzzyLikeThisQuery.java:209)
    at org.apache.lucene.sandbox.queries.FuzzyLikeThisQuery.rewrite(FuzzyLikeThisQuery.java:262)
    at org.elasticsearch.common.lucene.search.XFilteredQuery.rewrite(XFilteredQuery.java:93)
    at org.apache.lucene.search.IndexSearcher.rewrite(IndexSearcher.java:616)
    at org.elasticsearch.search.internal.ContextIndexSearcher.rewrite(ContextIndexSearcher.java:112)
    at org.apache.lucene.search.IndexSearcher.createNormalizedWeight(IndexSearcher.java:663)
    at org.elasticsearch.search.internal.ContextIndexSearcher.createNormalizedWeight(ContextIndexSearcher.java:126)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:281)
    at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:155)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:269)
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:135)
    ... 9 more

Full curl recreation is: https://gist.github.com/dadoonet/5031671

@ghost ghost assigned s1monw Mar 1, 2013
@s1monw
Copy link
Contributor

s1monw commented Mar 1, 2013

I created LUCENE-4809 for this. Its a lucene bug essentially and it should be fixed with the 4.2 upgrade

@s1monw
Copy link
Contributor

s1monw commented Mar 1, 2013

I just committed the fixes so this should be fixed once 4.2 is out and integrated

@s1monw
Copy link
Contributor

s1monw commented Mar 11, 2013

fixed by commit 11bf7a8

@s1monw s1monw closed this as completed Mar 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants