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: {&amp;quot;error&amp;quot;:{&amp;quot;trace&amp;quot;:&amp;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&amp;quot;,&amp;quot;code&amp;quot;:500}}
. in Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend-&gt;search() (line 1053 of modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php). Drupal\search_api\Entity\Server-&gt;search(Object) (Line: 494)
CommentFileSizeAuthor
#6 2921774.patch1.66 KBmkalkbrenner

Comments

JeroenT created an issue. See original summary.

mkalkbrenner’s picture

Can you provide the resulting solr query?
BTW that's totally easy with 8.x-2.x and enabling search_api_solr_devel

jeroent’s picture

mkalkbrenner,

Thanks for your quick response. This is the query:

Try to send Solr request => select?omitHeader=true&wt=json&json.nl=flat&q=%2A%3A%2A&start=0&rows=1000000&fl=ss_search_api_id%2Css_search_api_language%2Cscore%2Chash&fq=locs_field_coordinates%3A%5B%2A+TO+%2A%5D&fq=index_id%3A%22products%22&defType=edismax&qf=tm_aggregated_field+ts_field_description%5E1+ts_field_product_teaser_summary%5E1
GET => Array
(
    [omitHeader] => Array
        (
            [0] => true
        )

    [wt] => Array
        (
            [0] => json
        )

    [json.nl] => Array
        (
            [0] => flat
        )

    [q] => Array
        (
            [0] => *:*
        )

    [start] => Array
        (
            [0] => 0
        )

    [rows] => Array
        (
            [0] => 1000000
        )

    [fl] => Array
        (
            [0] => ss_search_api_id,ss_search_api_language,score,hash
        )

    [fq] => Array
        (
            [0] => locs_field_coordinates:[* TO *]
            [1] => index_id:"products"
        )

    [defType] => Array
        (
            [0] => edismax
        )

    [qf] => Array
        (
            [0] => tm_aggregated_field ts_field_description^1 ts_field_product_teaser_summary^1
        )

)
Received Solr response => 500 OK
mkalkbrenner’s picture

OK, it seems that the query builder needs a special handling for NULL for location fields:
locs_field_coordinates:[* TO *]

<>NULL gets converted to [* TO *]. What should it be for location fields?

mkalkbrenner’s picture

<&gt NULL gets converted to [* TO *]. What should it be for location fields?

Maybe it should be converted like this:
locs_field_coordinates:*

But we need tests first to reproduce the issue.

mkalkbrenner’s picture

Status: Active » Needs review
StatusFileSize
new1.66 KB

  • mkalkbrenner committed f6f5c53 on 8.x-2.x
    Issue #2921774 by mkalkbrenner: Empty check on "location" field results...
mkalkbrenner’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.