Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running WeBlog with Solr #172

Closed
kalotra opened this issue Jun 7, 2016 · 32 comments
Closed

Running WeBlog with Solr #172

kalotra opened this issue Jun 7, 2016 · 32 comments
Assignees

Comments

@kalotra
Copy link

kalotra commented Jun 7, 2016

Hello.

Is it possible to run weblog with Solr? We're running Sitecore 8.1 Update 1 and using Solr and WeBlog conflicts with it. Any thoughts around this would be very helpful.

@alan-null
Copy link
Contributor

Hi @kalotra
I don't know if anybody from the team ever tested it.
Current content search configuration has Lucene configuration only.
We would have to investigate that.

@adeneys
Copy link
Contributor

adeneys commented Jun 10, 2016

Can you specify the nature of the conflict?

As @alan-null mentioned, the OOTB content search configuration for WeBlog is based on the Lucene content search configuration. If you've swapped your solution over to use SOLR then you'll need to adjust the WeBlog content search configuration to use SOLR as well. This shouldn't be too hard as the config is pretty basic, leveraging the default provider config for most things.

@kalotra
Copy link
Author

kalotra commented Jun 24, 2016

Hello.
We decided to stick to Lucene for the content search so no problem with WeBlog now. However, we're having an issue submitting comment on PROD CD server. DEV CA/CD works fine. PROD CA works fine as well, but submitting comments from PROD CD returns following error:

"The request for security token could not be satisfied because authentication failed."

The configuration is same across servers accept the fact that PROD CD is running over https://. I can access http://[authoring server address]/sitecore modules/web/WeBlog/Comment.svc from PROD CD server. However, submitting comments from the CD node returns above error. I have advised the network team to double check access between servers. Meanwhile, I'd appreciate any idea/suggestions from your side.

@adeneys
Copy link
Contributor

adeneys commented Jul 3, 2016

The above issue is unrelated to SOLR, so please open a new issue for it.

I'll leave this current issue open until we add a SOLR specific config file.

@PavanOS
Copy link

PavanOS commented Feb 7, 2017

If anyone wants SOLR configuration I did it and indexing worked for me. Shared the changed configuration, please download the attached file and remove .TXT extension
WeBlog.ContentSearch.config.txt

@SMRaxa
Copy link

SMRaxa commented Feb 18, 2017

Hi Pavan,
I used your configuration file to switch to Solr but its not working, Its not indexing the contents of blog and Blog posts are not displaying, I checked all configurations and everything seems fine but I don't know where I made mistake and its not showing up. I am using WeBlog 3.0 and Sitecore 8.2 XP. Sitecore search with Solr is working fine, can you please let me know how can I troubleshoot. Thank you.

@SMRaxa
Copy link

SMRaxa commented Feb 18, 2017

Please find below the config files converted to Solr search, I really need to fix this issue, please help me.

WeBlog.config.zip

@hptbee
Copy link

hptbee commented Mar 28, 2017

Anyone fixed this issue ?

@PavanOS
Copy link

PavanOS commented Mar 30, 2017

I did debug this issue a while ago , looks like the Solr query being sent by weblog code has issue, so it is not working even configs are right. So waiting for code fix.

@SMRaxa
Copy link

SMRaxa commented Mar 30, 2017

Yes, you are right. I also debugged it and got the same issue, so I copied the code of weblog and updated all of its queries into my solution.

@PavanOS
Copy link

PavanOS commented Mar 31, 2017

SMRaxa, that's awesome. Can you please share the weblog code that you changed. You can email it to me at pavanomtri@yahoo.com

@hptbee
Copy link

hptbee commented Mar 31, 2017

I had change config, and solr can work in admin site.
But on page Blog in user site error.
Inner Exception: Value cannot be null. Parameter name: fieldNameTranslator.

@SMRaxa Can you share it here or send to my mail hptbee@gmail.com ? Thanks you very much.

@SMRaxa
Copy link

SMRaxa commented Apr 1, 2017

I copied the GetBlogEnteries method from WeBlog solution and added it into my solution and updated it as below. I created my own controller/action which calls this method to fetch blog entries and then render the view.

`public IEnumerable GetBlogEntries(string tag, string category, int maxNumber = MaxPosts, DateTime? minimumDate = null, DateTime? maximumDate = null)
{

        var blog = Sitecore.Context.Database.Items[Templates.BlogHome.BlogId];//Blog ID
        

        List<EntryItem> result = new List<EntryItem>();
        var indexName = String.Format("sitecore_{0}_index", Sitecore.Context.Database.Name);

        if (!string.IsNullOrEmpty(indexName))
        {

            using (var context = ContentSearchManager.GetIndex(indexName).CreateSearchContext(SearchSecurityOptions.DisableSecurityCheck))
            {
                var builder = PredicateBuilder.True<EntryResultItem>();

                //var id = customBlogItem.BlogSettings.EntryTemplateID;
                builder = builder.And(i => i.TemplateId == Templates.BlogEntry.BlogEntry);
                builder = builder.And(i => i.Paths.Contains(blog.ID));
                builder = builder.And(i => i.Language.Equals(blog.Language.Name, StringComparison.InvariantCulture));
                builder = builder.And(item => item.DatabaseName.Equals(Context.Database.Name, StringComparison.InvariantCulture));

                // Tag
                if (!string.IsNullOrEmpty(tag))
                {
                    builder = builder.And(i => i.Tags.Contains(tag));
                }

                // Categories
                // This search is not working so I commented it for now, will check it later
                //if (!string.IsNullOrEmpty(category))
                //{
                //    var categoryItem = ManagerFactory.CategoryManagerInstance.GetCategory(blog, category);

                //    // If the category is unknown, don't return any results.
                //    if (categoryItem == null)
                //        return new EntryItem[0];
                //    /*#if SC70
                //                            var normalizedID = Sitecore.ContentSearch.Utilities.IdHelper.NormalizeGuid(categoryItem.ID);
                //                            builder = builder.And(i => i.Category.Contains(normalizedID));
                //    #else*/
                //    builder = builder.And(i => i.Category.Contains(categoryItem.ID));
                //    //#endif

                //}

                

                if (minimumDate != null)
                    builder = builder.And(i => i.EntryDate >= minimumDate);

                if (maximumDate != null)
                    builder = builder.And(i => i.EntryDate < maximumDate);

                var indexresults = context.GetQueryable<EntryResultItem>().Where(builder);

                if (indexresults.Any())
                {
                    var itemResults = indexresults.Select(indexresult => indexresult.GetItem()).ToList();

                    //The above category filter was not working so I commented above and used this way because don't have time to configure index
                    if (!string.IsNullOrEmpty(category))
                    {
                        itemResults = itemResults.Where(item => GetCategories(item).Any(x => x.ToLower().Contains(category.ToLower()))).ToList();
                    }

                    result = itemResults.Where(item => item != null).Select(i => new EntryItem(i)).ToList();
                    result = result.OrderByDescending(post => post.EntryDate.DateTime).ThenBy(post => post.Created).Take(maxNumber).ToList();
                }
            }
        }

        return result.ToList();
    }`

@AyushmatiVelir
Copy link

AyushmatiVelir commented May 5, 2017

We need to change the Solr core names to remove capital casing i.e. use 'weblog-master' instead of 'WeBlog-master'.
This is because solr stores the _indexname field value(which is added in the query filter) as lowercase and solr querying is case sensitive(so the field value and index names don't match up in case of camel casing).

That eliminated the need to rewrite any code. Please update the core names in the necessary weblog config files.

@varitw
Copy link

varitw commented Jun 16, 2017

To fix the category issue, you need to add the following fieldmap into WeBlog.ContentSearch.config

<fieldType fieldName="category" returnType="guidCollection"/>

@teggis
Copy link

teggis commented Jul 5, 2017

After switching 'weblog-web' instead of 'WeBlog-web' I am now getting the error Index WeBlog-web was not found. I cannot find where this is trying to call WeBlog-web. Any Ideas where to search or anyone else having this problem

@AyushmatiVelir
Copy link

AyushmatiVelir commented Jul 5, 2017

Please update the index name in WeBlog.ContentSearch.Web.config.
ex: --index id="weblog-web" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider"--

@teggis
Copy link

teggis commented Jul 5, 2017

Yes I had already done that see below
id="weblog-web" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider"
I just cant find where it is calling the index by the capital case.

@varitw
Copy link

varitw commented Jul 5, 2017 via email

@teggis
Copy link

teggis commented Jul 6, 2017

Thank you varitw that fixed the issue.

@teggis
Copy link

teggis commented Sep 29, 2017

Is anyone have the issue with the tag cloud not returning posts when there is a multiple word tag? It works in Lucene just fine but with Solr it does not work. Example is: "working today". With Solr click on "working today" returns nothing but Lucene brings backs post's with this tag. In Solr if you search by one or the other word's "working" or "today" it returns posts. Any help will be appreciated.

@efezter
Copy link

efezter commented Sep 25, 2018

Hi all

I get 'Could not find add method: IncludeTemplate (type: Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration)' error after replacing WeBlog.ContentSearch.config with the file provided by @PavanOS. Any recommendation?

@andyram2k
Copy link

Hi,
We're upgrading to 9.2 currently, and with that we've updated the files to work with 9.2, and SOLR from Lucene. I've attached our config files which work with SOLR in case it helps anyone / the project team.

Andy

weblog.zip

@alan-null
Copy link
Contributor

Thank you, Andy (@andyram2k )

adeneys added a commit that referenced this issue Oct 27, 2019
@ghost
Copy link

ghost commented Dec 6, 2019

I have updated our 9.2 code base to all these changes (incl. commit #172), and now after rebuilding the indexes loading my page I get the following exception:

[FormatException: Could not map index document field to property "Category" on type Sitecore.Modules.WeBlog.Search.SearchTypes.EntryResultItem : Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). Actual value: {8AE09F4E-40CA-4AC3-BC17-51DF337CBB6C}|{EABEB6B2-41B3-4707-B156-64994831249C}] Sitecore.ContentSearch.DocumentTypeMapInfo.SetProperty(Object target, String propertyName, String documentFieldName, Object value) +1087 Sitecore.ContentSearch.DefaultDocumentMapper1.MapFieldValuesToType(IDictionary2 fieldValues, TElement result, DocumentTypeMapInfo documentTypeMapInfo) +1841 Sitecore.ContentSearch.DefaultDocumentMapper1.MapToType(TDocument document, SelectMethod selectMethod, IEnumerable1 virtualFieldProcessors, IEnumerable1 executionContexts, SearchSecurityOptions securityOptions) +327
Sitecore.ContentSearch.SolrProvider.d__21.MoveNext() +291
System.Collections.Generic.List1..ctor(IEnumerable1 collection) +526
System.Linq.Enumerable.ToList(IEnumerable1 source) +69 Sitecore.Modules.WeBlog.Managers.EntryManager.GetBlogEntries(Item blogRootItem, EntryCriteria criteria, ListOrder resultOrder)

And here a cut from the actual index:

"category_sm":["{8AE09F4E-40CA-4AC3-BC17-51DF337CBB6C}|{EABEB6B2-41B3-4707-B156-64994831249C}"]

Does this look right?

@ghost
Copy link

ghost commented Dec 6, 2019

image

What's the difference between stringArray and stringCollection? Both are collections, but more interestingly, the Category property in EntryResultItem is ID[] and not string[] (like Tags).

@adeneys
Copy link
Contributor

adeneys commented Dec 8, 2019

Hi @djanjicek,
This is what I'm working on now. Trying to get the category field to index and deserialize properly.
I'm not sure which commit you took as your link is to this issue, but I imagine it was one from the feature/172-solr-support branch. We use gitflow, so any feature branch is a work-in-progress.

@ghost
Copy link

ghost commented Dec 8, 2019 via email

@ghost
Copy link

ghost commented Dec 13, 2019

@adeneys Any progress so far?

@adeneys
Copy link
Contributor

adeneys commented Dec 15, 2019

@djanjicek I've made a bit of progress and fixed the category issues, but I'm still validating.

@ghost
Copy link

ghost commented Dec 17, 2019

@adeneys Thank you very much! This seems to work.

@adeneys adeneys self-assigned this Dec 28, 2019
adeneys pushed a commit that referenced this issue Dec 28, 2019
adeneys added a commit that referenced this issue Dec 30, 2019
adeneys added a commit that referenced this issue Dec 30, 2019
@adeneys
Copy link
Contributor

adeneys commented Feb 11, 2020

Release 4.0 adds support for Solr when using Sitecore 9.x.

@adeneys adeneys closed this as completed Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests