The problem
In my browsers network tab I could see that the API returned status 400: "Object reference not set to an instance of an object".
In my log files I could find some further info:
Not terribly informative. I tried checking whatever relevant resources I could find on setting up SXA and search, such as setting_up/sxa_search, configuring/configure_sxa_indexing, and the SXA installation guide but all with no luck.
7248 10:19:18 WARN Results endpoint exception
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Sitecore.ContentSearch.SolrProvider
at Sitecore.ContentSearch.SolrProvider.SolrFieldNameTranslator.StripKnownCultures(String fieldName)
at Sitecore.ContentSearch.SolrProvider.SolrFieldNameTranslator.StripKnownExtensions(String fieldName)
at Sitecore.ContentSearch.SolrProvider.SolrFieldNameTranslator.ProcessFieldName(String fieldName, String fieldTypeKey, Type returnType, CultureInfo culture, String returnTypeString, Boolean aggressiveResolver)
at Sitecore.ContentSearch.SolrProvider.SolrFieldNameTranslator.GetIndexFieldName(MemberInfo member, CultureInfo culture)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitItemProperty(MemberExpression expression)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitBinary(BinaryExpression expression)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitBinary(BinaryExpression expression)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitWhereMethod(MethodCallExpression methodCall)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitWhereMethod(MethodCallExpression methodCall)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitWhereMethod(MethodCallExpression methodCall)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitWhereMethod(MethodCallExpression methodCall)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitCountMethod(MethodCallExpression methodCall)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.Parse(Expression expression)
at Sitecore.XA.Foundation.Search.Spatial.GenericQueryable`2.GetQuery(Expression expression)
at Sitecore.ContentSearch.Linq.Parsing.GenericQueryable`2.Execute[TResult](Expression expression)
at Sitecore.XA.Feature.Search.Controllers.SearchController.GetResults(String v, String q, String s, String l, String g, String o, Int32 e, Int32 p, String sig, String site, String itemid)
The solution
The solution is actually quite simple - the indexes aren't created automatically during installation and must be manually created. Easy peasy - once you think of it.
I'm unsure of the "right" way to do this, since it's not documented, but what I did was these simple steps:
I'm unsure of the "right" way to do this, since it's not documented, but what I did was these simple steps:
- Go to [solrpath]\server\solr and copy [mysitename]_master_index folder, name it sitecore_sxa_master_index
- Go into that folder, open core.properties and replace [mysite]_master_index to sitecore_sxa_master_index
- Delete the data folder
- Repeat steps 1-3 for web
- Restart the solr service
- Reindex the 2 new indexes from the controlpanel
This fixed my issues and search worked beautifully.
I posted on the Sitecore #sxa Slack that I believed this documentation was missing - and was later asked for a solution, so I thought I'd post it here as well, to help others find it.
Next version of SXA is supposed to automatically install these cores if you use SIF install.