mikemccand / luceneserver

A high performance "thin wrapper" HTTP REST server on top of Apache Lucene
Apache License 2.0
137 stars 35 forks source link

Weird intermittent exception "unrecognized parameters highlightQuery" #26

Closed mikemccand closed 8 months ago

mikemccand commented 8 months ago

I'm not sure why, but I intermittently see this exception:

Traceback (most recent call last):
  File "/home/ec2-user/src/github-ui/util.py", line 164, in handleOnePage
    html, headers = handler(path, isMike, environ)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/src/github-ui/handle.py", line 1699, in handleQuery
    result = send('search', query)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/src/github-ui/util.py", line 121, in send
    return self.processResponse(h)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/src/github-ui/util.py", line 147, in processResponse
    raise RuntimeError('Server returned HTTP %s, %s:\n%s' % (r.status, r.reason, s.decode('utf-8')))
RuntimeError: Server returned HTTP 500, Internal Server Error:
java.lang.IllegalArgumentException: unrecognized parameters:
{
 "highlightQuery":{
  "subQueries":[
   {
    "occur":"should",
    "query":{
     "field":"title",
     "boost":3.0,
     "text":"wunder",
     "class":"text"
    }
   },
   {
    "occur":"should",
    "query":{
     "field":"body",
     "boost":1.0,
     "text":"wunder",
     "class":"text"
    }
   },
   {
    "occur":"should",
    "query":{
     "field":"comment_body",
     "boost":1.0,
     "text":"wunder",
     "class":"text"
    }
   },
   {
    "occur":"should",
    "query":{
     "field":"key",
     "boost":3.0,
     "text":"wunder",
     "class":"text"
    }
   },
   {
    "occur":"should",
    "query":{
     "field":"all_users",
     "boost":1.0,
     "text":"wunder",
     "class":"text"
    }
   },
   {
    "occur":"should",
    "query":{
     "field":"other_text",
     "boost":1.0,
     "text":"wunder",
     "class":"text"
    }
   }
  ],
  "class":"BooleanQuery"
 }
}
    at org.apache.lucene.server.Server$ServerHandler._handle(Server.java:529)
    at org.apache.lucene.server.Server$ServerHandler.handle(Server.java:340)
    at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:98)
    at jdk.httpserver/sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:82)
    at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:101)
    at jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:871)
    at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:98)
    at jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:847)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1583)
mikemccand commented 8 months ago

OK I think I see the bug -- this happens if we request to highlight, but, there were no hits to highlight. In this case a bug in SearchHandler.java causes it to fail to "consume" the highlightQuery parameter.

mikemccand commented 8 months ago

Fixed with https://github.com/mikemccand/luceneserver/commit/84769d7ca984e8f720710193b4b718e4b9e4948f

I forgot to link to this issue in the commit message, grr.