Skip to content

Sitecore Forms disappear from form listing after Synthesis Solr search is run #110

@sitecorepm

Description

@sitecorepm

Happy Friday!

Do you want to request a feature or report a bug?
BUG

What is the current behavior?
After a Synthesis Solr search using GetSynthesisQueryable is run, forms no longer show up in the Sitecore Forms editor listing.
image

If the current behavior is a bug, please provide the steps to reproduce.

  1. Create a Sitecore Form
  2. Run a Synthesis query with GetSynthesisQueryable
  3. Refresh the forms listing page and see that the form you just created is gone.

What is the expected behavior?
Forms should not disappear

Please mention your Sitecore version and Synthesis version.
Sitecore 10.2 (yes I know (now) it's not technically supported... but I like living on the edge)
Synthesis 9.1.6

Detailed Description with potential fix
The credit for this sleuthing goes to Michael Doroshenko from Sitecore Support. In short, he found that after a Synthesis search was run the normal Sitecore SOLR search that runs to retrieve the list of forms was incorrectly setting the suffix on the is_template_b field to is_template_t. Then he dug into why... here's his last response:

"
I was running some additional tests and I reproduced the issue when I added Synthesis assemblies/configs and then executed a query using "GetSynthesisQueryable" call.
When such a query is executed, the default "fieldNameTranslator" property of sitecore_master_index is replaced by Synthesis.Solr.ContentSearch.SynthesisSolrFieldNameTranslator. The Synthesis.Solr.ContentSearch.SynthesisSolrFieldNameTranslator is not able to resolve the related field type correctly leading to this issue.
[...]
I think that the issue is related to the following class:
https://github.com/blipson89/Synthesis/blob/706ce71741bc9c826ff99993a4f139276f787d0a/Source/Synthesis.Solr/ContentSearch/SynthesisSolrFieldNameTranslator.cs

For some reason, the custom code directly uses Solr schema instead of working with the default Sitecore logic.
This method assumes that if a field is not present in the loaded Solr schema, it should be treated as a text field:

public override string GetIndexFieldName(string fieldName)
{
    if (_schema != null && (_schema.FindSolrFieldByName(fieldName) != null || _schema.SolrDynamicFields.Any(x => fieldName.EndsWith(x.Name.Substring(1)))))
        return fieldName;
    //at this point we can't be sure what type the data is in the field, our best bet would be a text field.
    return AppendSolrText(fieldName);
}

As far as I understand, the default Sitecore field mapping logic is just ignored and "is_template" field is loaded as text instead of boolean.

The default Sitecore implementation of that method just calls API to resolve the field type based on the configuration:

public override string GetIndexFieldName(string fieldName)
{
    return GetIndexFieldName(fieldName, (CultureInfo)null);
}

The module source code is on GitHub, so you can modify the related code and build an updated assembly.
I believe just calling "return base.GetIndexFieldName(fieldName, (CultureInfo)null);" instead of "return AppendSolrText(fieldName);" is enough to fix this issue.
Please note that it's not clear why the module calls "AppendSolrText(fieldName)", so it might impact the custom module logic.
"

I tried the recommended solution and that DID in fact fix the issue. I can create a PR for it if you want.

Thanks!

Paul

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions