I have a custom Search api query with an empty check on a solr location field:
$index = \Drupal::entityTypeManager()->getStorage('search_api_index')->load('products');
$query = $index->query();
$query->addCondition('field_coordinates', null, '<>');
$results = $query->execute();
When executing this query it results in an SearchApiSolrException:
Drupal\search_api_solr\SearchApiSolrException: An error occurred while trying to search with Solr: {&quot;error&quot;:{&quot;trace&quot;:&quot;java.lang.NullPointerException\n\tat java.lang.String.contains(String.java:2133)\n\tat org.apache.solr.util.SpatialUtils.parsePointSolrException(SpatialUtils.java:110)\n\tat org.apache.solr.schema.LatLonType.getRangeQuery(LatLonType.java:103)\n\tat org.apache.solr.parser.SolrQueryParserBase.getRangeQueryImpl(SolrQueryParserBase.java:1056)\n\tat org.apache.solr.parser.SolrQueryParserBase.getRangeQuery(SolrQueryParserBase.java:1050)\n\tat org.apache.solr.parser.QueryParser.Term(QueryParser.java:504)\n\tat org.apache.solr.parser.QueryParser.Clause(QueryParser.java:278)\n\tat org.apache.solr.parser.QueryParser.Query(QueryParser.java:162)\n\tat org.apache.solr.parser.QueryParser.TopLevelQuery(QueryParser.java:131)\n\tat org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:211)\n\tat org.apache.solr.search.LuceneQParser.parse(LuceneQParser.java:53)\n\tat org.apache.solr.search.QParser.getQuery(QParser.java:168)\n\tat org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:212)\n\tat org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:269)\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:173)\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:2440)\n\tat org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:723)\n\tat org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:529)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:347)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:298)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1691)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:119)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)\n\tat org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:534)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)\n\tat org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)\n\tat java.lang.Thread.run(Thread.java:748)\n&quot;,&quot;code&quot;:500}}
. in Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->search() (line 1053 of modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php). Drupal\search_api\Entity\Server->search(Object) (Line: 494)
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2921774.patch | 1.66 KB | mkalkbrenner |
Comments
Comment #2
mkalkbrennerCan you provide the resulting solr query?
BTW that's totally easy with 8.x-2.x and enabling search_api_solr_devel
Comment #3
jeroentmkalkbrenner,
Thanks for your quick response. This is the query:
Comment #4
mkalkbrennerOK, it seems that the query builder needs a special handling for NULL for location fields:
locs_field_coordinates:[* TO *]<>NULLgets converted to[* TO *]. What should it be for location fields?Comment #5
mkalkbrennerMaybe it should be converted like this:
locs_field_coordinates:*But we need tests first to reproduce the issue.
Comment #6
mkalkbrennerComment #8
mkalkbrenner