TYPO3-Solr / solr-typo3-plugin

An Apache Solr filter plugin to support TYPO3 access restrictions.
http://www.typo3-solr.com
Apache License 2.0
7 stars 5 forks source link

java.lang.NullPointerException when filtering docs indexed with an old TYPO3 schema #13

Closed dogawaf closed 5 years ago

dogawaf commented 7 years ago

Hello

I've migrated a solr index from 4 to 5, then from 5 to 6. Everything went fine. All my documents are now in the new solr installation.

But, searching with typo3access throw a java error when document from the old index are in the resultset. The error does not occur with fresh indexed document. I'm not a java expert, so I did not find any idea about the cause of this issue.

I wonder if you can help me with that. I could not reindex all the document with the new schema...

Below the search query, the java error, a working document and a failing document.

Search query http://solr:8984/solr/core_fr/select?facet=on&facet.prefix=jap&facet.field=spell&facet.limit=10&facet.mincount=1&fq=%7B%21typo3access%7D-1%2C0&fq=siteHash%3A%xxx%22&fl=spell&q.alt=%2A%3A%2A&omitHeader=true&wt=json&json.nl=map&q=&start=0

Java error

java.lang.NullPointerException
    at org.typo3.solr.search.AccessFilter.handleSingleValueAccessField(AccessFilter.java:114)
    at org.typo3.solr.search.AccessFilter.access$200(AccessFilter.java:46)
    at org.typo3.solr.search.AccessFilter$1.collect(AccessFilter.java:198)
    at org.apache.lucene.search.FilterLeafCollector.collect(FilterLeafCollector.java:43)
    at org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:221)
    at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:172)
    at org.apache.lucene.search.ConstantScoreQuery$ConstantBulkScorer.score(ConstantScoreQuery.java:84)
    at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:669)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:473)
    at org.apache.solr.search.SolrIndexSearcher.buildAndRunCollectorChain(SolrIndexSearcher.java:242)
    at org.apache.solr.search.SolrIndexSearcher.getDocListAndSetNC(SolrIndexSearcher.java:1899)
    at org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1616)
    at org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:617)
    at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:531)
    at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:295)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:153)
    at org.apache.solr.core.SolrCore.execute(SolrCore.java:2213)
    at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:654)
    at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:460)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:303)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:254)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1160)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1092)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:119)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
    at org.eclipse.jetty.server.Server.handle(Server.java:518)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:246)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:156)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:745)

Document indexed with ext:solr v6

{
        "id":"b0152ba4275701bfcb8e76a43135ab195ad5ef07/pages/33558/0/0/0",
        "site":"www.example.org",
        "siteHash":"xxx",
        "type":"pages",
        "uid":33558,
        "pid":28484,
        "variantId":"7d12afff9fc1aac71587ddb2d18d1dca9332c698/pages/33558",
        "typeNum":0,
        "created":"2017-05-22T11:30:22Z",
        "changed":"2017-06-23T17:12:42Z",
        "rootline":["0-27734/",
          "1-27734/28484/",
          "2-27734/28484/33558/"],
        "access":["c:0"],
        "title":"Newsletter Réseau #42",
        "titleExact":"Newsletter Réseau #42",
        "subTitle":"",
        "navTitle":"",
        "author":"",
        "description":"",
        "abstract":"",
        "content":"",
        "contentExact":"",
        "teaser":"",
        "url":"xxx",
        "_version_":1571035085737558016,
        "indexed":"2017-06-23T22:10:11Z"
}

Document indexed with ext:solr v3

{
        "id":"c200386c357def0dcaaac72ce88f564d5275fa78/pages/12049/0/0/0",
        "site":"www.example.org",
        "siteHash":"xxx",
        "type":"pages",
        "uid":12049,
        "pid":12046,
        "typeNum":0,
        "created":"2013-05-07T17:09:36Z",
        "changed":"2016-08-01T17:48:45Z",
        "rootline":["0-12036",
          "1-12036/12037",
          "2-12036/12037/12038",
          "3-12036/12037/12038/12046",
          "4-12036/12037/12038/12046/12049"],
        "access":["c:0"],
        "title":"Charte éthique",
        "subTitle":"",
        "navTitle":"",
        "author":"",
        "description":"",
        "abstract":"",
        "content":"",
        "teaser":"",
        "url":"xxx",
        "_version_":1542898903082336256,
        "indexed":"2016-08-17T08:37:36Z"
}

java 1.8.0_45-b14 ext:solr 6.1.0 solr-typo3-plugin 2.0.0

timohund commented 7 years ago

@dogawaf

Hi, there is a huge difference between Solr 4 & 6. I think the source of the problem could be that the access field was changed from single value to multivalue. Currently we propose to reIndex you documents. I guess a automatic migration could be quite complex and reindexing is quicker.

baschny commented 5 years ago

I just stumbled over this issue, and in my case got the same Exception when searching. That is not an index problem. The &fq=%7B%21typo3access%7D-1%2C0 part of the URL is the problem. If I change it to &fq={!typo3access}-1,0 (urldecoded), I do not get the exception anymore. Is this maybe an Apache Solr bug? Maybe we should urldecode before sending the query to Solr? Why is it urlencoded in the first place??

timohund commented 5 years ago

I guess we have to analyze that. It could be, that there is a different behaviour between tomcat and jetty now.

timohund commented 5 years ago

@baschny, which versions of EXT:solr and the plugin are you using? What is the datatype of the access field in your schema? Is it multiValued="true"? And did you build a fresh new index or update the schema?

baschny commented 5 years ago

@timohund thanks for returning. I think the problem might be that we have a different Schema running on Solr as the extension expects, so there is a chance that this could be the problem. Will clear that up today, as I already requested the hoster (not our own infrastructure) to reinstall Solr with the correct schema. I will get back here if this fixed the problem.

timohund commented 5 years ago

Ok, as background information. The access field was changed from singleValue to multiValue, but both should still work, but it requires a re-indexing, so when you have the data as singleValue but the schema as multivalue, this could be a problem. But EXT:solr requires to have it as multiValue field since EXT:solr 6.0.0

rajupaladiya commented 5 years ago

Hi community, Any update on this? I'm facing same issue.

My Query is http://localhost:8983/solr/403_400_2/select?indent=on&wt=json&mm=0%25& facet.field={!ex=Category}Category& facet.field=Manufacturer& facet.field=Vendor& start=0& fq={!tag=Category}& fq=Price:[0+TO+9999999999999]& rows=6& version=2.2& bq=& facet.query=AverageRating:[4+TO+5]& facet.query=AverageRating:[3+TO+5]& facet.query=AverageRating:[2+TO+5]& facet.query=AverageRating:[1+TO+5]& q=(apple)& defType=edismax& spellcheck.q=(apple)& qf=Name^1+ShortDescription^1+FullDescription^1+CategoryCopy^1+ManufacturerCopy^1+Sku^1+ChildSku^1+GTIN^1+nGramContent+Tag+ManufacturerPartNumber+CustomProperties& spellcheck=true& stats=true& facet.mincount=1& facet=true& wt=xml& spellcheck.collate=true& stats.field=Price

Out put:

{ "responseHeader":{ "status":500, "QTime":5, "params":{ "mm":"0%", "facet.field":["{!ex=Category}Category", "Manufacturer", "Vendor"], "indent":"on", "start":"0", "fq":["{!tag=Category}", "Price:[0 TO 9999999999999]"], "rows":"6", "version":"2.2", "bq":"", "facet.query":["AverageRating:[4 TO 5]", "AverageRating:[3 TO 5]", "AverageRating:[2 TO 5]", "AverageRating:[1 TO 5]"], "q":"(apple)", "defType":"edismax", "spellcheck.q":"(apple)", "qf":"Name^1 ShortDescription^1 FullDescription^1 CategoryCopy^1 ManufacturerCopy^1 Sku^1 ChildSku^1 GTIN^1 nGramContent Tag ManufacturerPartNumber CustomProperties", "spellcheck":"true", "stats":"true", "facet.mincount":"1", "wt":["json", "xml"], "facet":"true", "spellcheck.collate":"true", "stats.field":"Price"}}, "error":{ "trace":"java.lang.NullPointerException\r\n\tat org.apache.solr.search.QueryResultKey.<init> QueryResultKey.java:52)\r\n\tat org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1550)\r\n\tat org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:611)\r\n\tat org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:533)\r\n\tat org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:295)\r\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:166)\r\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:2299)\r\n\tat org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:658)\r\n\tat org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:464)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:345)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:296)\r\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1691)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\r\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\r\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)\r\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:119)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)\r\n\tat org.eclipse.jetty.server.Server.handle(Server.java:534)\r\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)\r\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)\r\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)\r\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)\r\n\tat org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)\r\n\tat java.lang.Thread.run(Unknown Source)\r\n", "code":500}}

Documents on query: http://localhost:8983/solr/403_400_2/select?fq=apple&indent=on&q=*:*&wt=json

{ "responseHeader":{ "status":0, "QTime":1, "params":{ "q":"*:*", "indent":"on", "fq":"apple", "wt":"json"}}, "response":{"numFound":2,"start":0,"docs":[ { "Id":4, "Name":"Apple MacBook Pro 13-inch", "NameCopy":"Apple MacBook Pro 13-inch", "ShortDescription":"A groundbreaking Retina display. A new force-sensing trackpad. All-flash rchitecture. Powerful dual-core and quad-core Intel processors. Together, these features take the notebook to a new level of performance. And they will do the same for you in everything you create.", "SeName":"apple-macbook-pro-13-inch", "Sku":"AP_MBP_13", "OldPrice":0.0, "Price":1800.0, "IsRental":false, "RentalPricePeriodId":0, "RentalPriceLength":0, "CallForPrice":false, "CustomerEntersPrice":false, "AvailableForPreOrder":false, "DisableBuyButton":false, "ImageURL":"//localhost:15536/images/thumbs/0000024_apple-macbook-pro-13-inch_415.jpeg", "ManufacturerID":[1], "Manufacturer":["Apple!!1!!"], "smanufacturer":["Apple!!1!!"], "CreatedDate":"2018-08-20T03:19:39.280Z", "CategoryID":[3], "TagID":[1, 2, 4], "Category":["Notebooks!!2!!"], "scategory":["Notebooks!!2!!"], "Tag":["awesome", "computer", "compact"], "TimeStamp":"2018-09-11T05:53:52.149Z", "f_CPU+Type":["Intel+Core+i5"], "Attributes":["Intel+Core+i5", "4+GB"], "sf_CPU+Type":["Intel+Core+i5"], "f_Memory":["4+GB"], "sf_Memory":["4+GB"], "CDO_3":2, "MDO_1":1, "VendorID":0, "AllowCustomerReviews":true, "ApprovedRatingSum":5, "ApprovedTotalReviews":1, "AverageRating":5.0, "ProductType":5, "IsTaxExempt":false, "TaxCategoryId":2, "TotalVariants":0, "StockAvailability":true, "MarkAsNew":false, "DisableWishlistButton":false, "RoleID":[1, 2, 3, 4, 5], "_version_":1611289311844499456}, { "Id":17, "Name":"Apple iCam", "NameCopy":"Apple iCam", "ShortDescription":"Photography becomes smart", "SeName":"apple-icam", "Sku":"APPLE_CAM", "OldPrice":0.0, "Price":1300.0, "IsRental":false, "RentalPricePeriodId":0, "RentalPriceLength":0, "CallForPrice":false, "CustomerEntersPrice":false, "AvailableForPreOrder":false, "DisableBuyButton":false, "ImageURL":"//localhost:15536/images/thumbs/0000040_apple-icam_415.jpeg", "ManufacturerID":[1], "Manufacturer":["Apple!!1!!"], "smanufacturer":["Apple!!1!!"], "CreatedDate":"2018-08-20T03:19:46.073Z", "CategoryID":[6], "Category":["Camera+%26+photo!!1!!"], "scategory":["Camera+%26+photo!!1!!"], "TimeStamp":"2018-09-11T05:53:52.324Z", "CDO_6":1, "MDO_1":1, "VendorID":0, "AllowCustomerReviews":true, "ApprovedRatingSum":4, "ApprovedTotalReviews":1, "AverageRating":4.0, "ProductType":5, "IsTaxExempt":false, "TaxCategoryId":2, "TotalVariants":0, "StockAvailability":true, "MarkAsNew":false, "DisableWishlistButton":false, "RoleID":[1, 2, 3, 4, 5], "_version_":1611289311919996928}] }}

rajupaladiya commented 5 years ago

I just stumbled over this issue, and in my case got the same Exception when searching. That is not an index problem. The &fq=%7B%21typo3access%7D-1%2C0 part of the URL is the problem. If I change it to &fq={!typo3access}-1,0 (urldecoded), I do not get the exception anymore. Is this maybe an Apache Solr bug? Maybe we should urldecode before sending the query to Solr? Why is it urlencoded in the first place??

this solution is not working at my end.

timohund commented 5 years ago

@rajupaladiya In your query typo3access is not present at all, what kind of query is that. What v ersion of Apache Solr, EXT:solr and the accessfilter plugin are you using?

rajupaladiya commented 5 years ago

@timohund - Hey thank you for asking. I forget to value in fq after upgrade to my code in Asp.Net CORE and SolrNet. I've fixed and filtering and faceting is now working fine. Thank you

timohund commented 5 years ago

@rajupaladiya does this mean that we can close this issue from your perspective?

rajupaladiya commented 5 years ago

@timohund - yes sure. You can close for my issue.