Siecore template field type resolution and solr when performing search query with sort - solr

I'm trying to perform a search sort using Sitecore 9.3 and SXA. The default search configuration allows the user to sort by 'Title'. The search logs shows queries with &sort=title_t desc which is expected.
If I change the sort criteria from Title to Other Title via /sitecore/content/[site name]/Global/Settings/Facets/Title to a field other than title, I no longer get results from the search results call.
Looking in the search log shows that Other Title is not being resolved to other_title_t with the error ERROR Solr Error : [sort param field can't be found: other_title ]
The Sitecore documentation https://doc.sitecore.com/developers/93/platform-administration-and-architecture/en/using-solr-field-name-resolution.html described the mechanism for resolving fields to the correct type using index config
<fieldType
fieldTypeName="html|rich text|single-line text|multi-line text|text|memo|image|reference"
returnType="text"
/>
...
</fieldTypes>
which is then used with the the type match to append _t to the field name
<typeMatches hint="raw:AddTypeMatch">
<typeMatch
typeName="text"
type="System.String"
fieldNameFormat="{0}_t"
cultureFormat="_{1}"
settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration,
Sitecore.ContentSearch.SolrProvider"
/>
</typeMatches>
This does not appear to be working for sort.
I've found that adding the fieldName (rather then rely on the preconfigured type mapping ) works and result in other_title_t being used as the query sort.
<fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="other title" returnType="string" />
</fieldNames>
</fieldMap>
Should sort field resolution work via type field mapping already? Is this a bug?

Related

Search view solr Drupal

i'm having troubles on setting up Search API Solr on Drupal 8.
I have installed the modules:
Search API
Search Pages
Solr search
Solr search Defaults
Facets
I have indexed contents and configure the data source to have special content types. When i start a search on the view, solr search api returns two errors:
first is:
Notice: Array to string conversion in Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->createId() (line 1098 of modules/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php).
that i found issue was the item id as an array ({ [0]=> string(16) "entity:node/2:fr" }) called at extractResults function to get solr_id
following by:
Warning: Illegal offset type in Drupal\search_api\Query\ResultSet->addResultItem() (line 97 of modules/search_api/src/Query/ResultSet.php).
Drupal\search_api\Query\ResultSet->addResultItem(Object) (Line: 1469)

Error adding field 'field_name'-'field_value' msg=For input string: \"field_Value\"

We are struggling to import certain files into Solr occasionally. It seems like certain documents have weird meta data (values), not sure if it might be from eccentric word processor or something else. See two examples here:
Type: Solarium\Exception\HttpException
Message: Solr HTTP error: OK (400)
{"responseHeader":{"status":400,"QTime":49},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","java.lang.NumberFormatException"],"msg":"ERROR: [doc=3932487729] Error adding field 'brightness_value'='6.18' msg=For input string: \"6.18\"","code":400}}
And
Type: Solarium\Exception\HttpException
Severity: error --> Exception: Solr HTTP error: OK (400)
{"responseHeader":{"status":400,"QTime":72},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","java.lang.NumberFormatException"],"msg":"ERROR: [doc=16996] Error adding field 'version'='5.3.1' msg=For input string: \"5.3.1\"","code":400}}
How do we prevent these issues? We are not in control of the documents, so need to fix it on the server.
Define the field type explicitly in the schema instead of relying on Solr to create the field type for you - the first document that contains the field will make Solr guess the type of the field, and if later documents doesn't match the same, expected format, you'll get an error like this.
Always define the schema for a collection when using it in production or in an actual application - the schemaless mode is really neat for prototyping and experimenting, but in an actual application you want the types to be well defined.

How to query custom AEM metadata in Solr

I've done Solr integration with Remote solr server and all the indexes were created, everything is fine.
Problem: I am not getting search result when I tried with OOTB metadata (dc:title) images though DAM Console search and asset viewer. It works only when I search on the node name GeoCube_Datasheet.pdf (Node name of type dam:Asset) . After I added a custom metadata for an Asset under jcr:content/metadata node, lets say dam:custom of type String, after I added another node under oak:index with below properties :
jcr:primaryType=oak:QueryIndexDefinition, reindex=true ( type Boolean) ,
propertyNames=dam:custom (type Name[]), type = property (type String).
After I modified schema.xml of Solr as :
<field name="dam:custom" type="matchall" />
After doing above configuration I can see the index is created in Solr Admin console. Solr admin console returns json output.
"path_exact": "/content/dam/geometrixx/portraits/scott_reynolds.jpg/
jcr:content/metadata", "jcr:primaryType": [ "nt:unstructured" ],
"dam:custom": [ "helloworld" ],
But When I do fulltext search in DAM console/ Asset viewer then Querybuilder does not return anything. But When I use default search engine (Lucene) then it returns records based on custom metadata.
For testing purpose when I executed this somehost:port/bin/querybuilder.json?fulltext=helloworld&type=dam:Asset then it does not return anything but it returns resukt when I executed somehost:port/bin/querybuilder.json?fulltext=helloworld&type=nt:unstructured
Please let me know what I'm missing here and how to get search result based on metadata
Thanks for your help!
You need to change Apache Jackrabbit Oak Solr Query index provider configuration in the felix console and enable the query time aggregation.

Solr 4.3.0 External File Field: despite I followed the official reference, I cannot get it to work

I have a Solr multicore instance and I'm trying to get advantage from the External File Field feature, but with no success.
Here's the fieldType definition
<fieldType name="ext_tags" class="solr.ExternalFileField" keyField="doc_id" />
Notice the reference guide reports an example with a few more attributes
defVal="" stored="false" indexed="false" valType="string"
but I guess they're from Solr version 3 because If I add them in my schema.xml, I get an error starting the instance.
Here's the field definition
<field name="deal_tags" type="ext_tags" indexed="false" stored="true" required="false" />
Here's the external data file name ( in $SOLR_HOME/data )
external_deal_tags.txt
Here's the instance dir ($SOLR_HOME)
/opt/solr-4.3.0/deal-ws/cores/it_IT/
Here's an excerpt from the data file (UTF-8 encoded, sorted by doc_id that is a MD5 hash)
003c9256f23da49233fc0b253f7a93cb=8;12
0050188629a8c0e3f89bcd6a7cb77b3a=6;7;13;33;35;38
009c3932933b173072054e3d81527b05=6
Here's the URL I call
http://localhost:8080/solr/it_IT/select?q=*:*&wt=json&fl=deal_tags&rows=3&indent=yes
Here's the response I get
{
"responseHeader":{
"status":0,
"QTime":116},
"response":{"numFound":3678,"start":0,"docs":[
{},
{},
{}]
}}
Even if I change the rows param to 4000 (i have 3678 documents in the index) I get no ext_tags
After modifying the schema.xml file, I restarted Tomcat many times and I also restarted the hosting machine.
What have I missed?
* UPDATE *
During my quest for answers, I found out the problem was possibly in the way I queried Solr. I tried modifying the query using field()
http://localhost:8080/solr/it_IT/select?q=*:*&wt=json&fl=field(deal_tags)&rows=3&indent=yes
and this is what I get now
{
"responseHeader":{
"status":0,
"QTime":2},
"response":{"numFound":3678,"start":0,"docs":[
{ "field(deal_tags)":0.0},
{ "field(deal_tags)":0.0},
{ "field(deal_tags)":8.0}]
}}
I expected to get strings instead I get something formatted as a decimal number:
- first result: expected 56;57 -> 0.0
- second result: expected blank -> 0.0 (its doc_id is not in the external file)
- third result: expected 8 -> 8.0
So, it seems I need to inform Solr I expect this value to be treated as a string but I don't get where to set this configuration.
Any idea?
Ok, I found out the what was the problem. I took a look in the log file ant here's what I got
Caused by: org.apache.solr.common.SolrException: Only float and pfloat (Trie|Float)Field are currently supported as external field type.
So, I cannot use strings as external values.

Solr 4.0, TextField query gives NullPointerException

I have a field in my Solr schema like -
Type - <fieldType name="text" class="solr.TextField" positionIncrementGap="100"/>
Declaration - <field name="description" type="text" indexed="true" stored="true"/>
This description field has values for some documents and no data for the remaining. I am not explicitly setting anything when there is no data for the description field as it is not a required field.
The problem is when i query using - description:*. I get a NullPointerException.
I have not changed the schema. Also when I query description:abc it works however for description:* and description:abc* it gives a NullPointerException.
Is it the correct behavior?
Are the text fields required to be given "" values when we do not have to set it?
Exception -
"error":{
"trace":"java.lang.NullPointerException\n\tat
org.apache.solr.schema.TextField.analyzeMultiTerm(TextField.java:139)\n\tat org.apache.solr.search.SolrQueryParser.analyzeIfMultitermTermText(SolrQueryParser.java:147)\n\tat
org.apache.solr.search.SolrQueryParser.getWildcardQuery(SolrQueryParser.java:203)\n\tat
org.apache.lucene.queryparser.classic.QueryParserBase.handleBareTokenQuery(QueryParserBase.java:1049)\n\tat
org.apache.lucene.queryparser.classic.QueryParser.Term(QueryParser.java:358)\n\tat
org.apache.lucene.queryparser.classic.QueryParser.Clause(QueryParser.java:257)\n\tat
org.apache.lucene.queryparser.classic.QueryParser.Query(QueryParser.java:181)\n\tat
org.apache.lucene.queryparser.classic.QueryParser.TopLevelQuery(QueryParser.java:170)\n\tat
org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:120)\n\tat
org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:72)\n\tat
org.apache.solr.search.QParser.getQuery(QParser.java:143)\n\tat
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:118)\n\tat
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:185)\n\tat
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)\n\tat
org.apache.solr.core.SolrCore.execute(SolrCore.java:1699)\n\tat
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:455)\n\tat
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:276)\n\tat
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1337)\n\tat
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484)\n\tat
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)\n\tat
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)\n\tat
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)\n\tat
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)\n\tat
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)\n\tat
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)\n\tat
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)\n\tat
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)\n\tat
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)\n\tat
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)\n\tat
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)\n\tat
org.eclipse.jetty.server.Server.handle(Server.java:351)\n\tat
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)\n\tat
org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)\n\tat
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)\n\tat
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)\n\tat
org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)\n\tat
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)\n\tat
org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)\n\tat
org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)\n\tat
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)\n\tat
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)\n\tat
java.lang.Thread.run(Thread.java:679)\n",
"code":500}}
A field of type solr.TextField has to have a Tokenizer associated with it otherwise it fails for wild character search.
I created a Jira bug for the same here.
It should work and does normally work.
Did you by any chance change field type definition and then did not do a full-reindex (delete old index and so on)?
I have seen this before but it seemed to have gone away after the index was fully rebuilt. May be something to do with left-over definitions on Lucene level.

Resources