Coder Social home page Coder Social logo

sitecore.algolia's Introduction

Sitecore search provider for Algolia

Algolia is a Hosted Search API that delivers instant and relevant results. This project implements Search Provider for Algolia in Sitecore.

How to setup

Find right Nuget package for your Sitecore version. Currenly project supports all Sitecore versions from 7.0 to 8.1 you can find versions matrix below:

Add Nuget package to your Visual Studio web project for Sitecore. Package will add all required DLLs. Config files should be implemented manually.

Below you can find instructions for configs setup applicable for Sitecore 8.1. Different Sitecore versions may requre slightly different configuration. Use default Lucene search config files to identify these variations.

Test project includes sample configuration files:

Copy these files into site-root/App_Config/Include folder. Now we need to make some changes to connect index with your Algolia account and filter data to include only relevant content.

Setup Index Configuration

Find commented include section

<!--<include hint="list:AddIncludedTemplate">
    <HomePage>{9CAAECFD-3BEB-44B1-9BE5-F7E30811EF2D}</HomePage>
    <ContentPage>{520A275F-6104-4690-8BCD-36B86BAD8D4E}</ContentPage>
</include>-->

Uncomment it and replace Ids in that section with Ids of templates you want to index. Typically that will be templates for pages.

Setup Index Definition

Index has some parameters required for Algolia connection:

  • applicationId - Application ID
  • fullApiKey - Admin API Key
  • indexName - Index Name.

All these values defined in Algolia Api Keys page.

<Site>website</Site>

Site parameter stores name of your site. That value will be used to define some site specific values like targetHostName.

<strategies hint="list:AddStrategy">
    <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster" />
</strategies>

Strategy is used to control what causes by Sitecore to update data in search index. This is standard Sitecore config and you can find more information about that in John West's blog post

<locations hint="list:AddCrawler">
    <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
        <Database>master</Database>
        <Root>/sitecore/content/Home</Root>
    </crawler>
</locations>

Crawler is a class that reads data from Sitecore database before it will be added to the index. This is also standard Sitecore configuration, although we need to do some changes here.

  • Database - align this with strategy. syncMaster should work with master database and onPublishEndAsync should work with web or whatever is your publishing target database.
  • Root - Crawling root item. Typically that will be homepage of your site

Why another provider?

Sitecore supports Lucene and Solr, other vendors have their engines like Coveo. So, why anybody wants to build one more provider? Because it is different:

  • Algolia is cool, blazing fast, requires no maintenance and easily configurable
  • Algolia includes modern instantsearch.js UX Framefork that simplifies construction of custom Search pages
  • Search Provider designed for Domain search and Multitenancy

Is there anything you cannot do with this provider?

Algolia is a razor comparing to swiss army knife. Index designed for speed and easy use and do not implement all the features that generic search engine has. As a result Algolia cannot replace default Sitecore indexes.

This provider includes only crawling part (code that sends data to the index). Linq to Search is not included and not on the roadmap. To make it fast, search has to be run on client side. Check Algloa JS UI instantsearch.js or join me in Algolia simple UI for Sitecore

sitecore.algolia's People

Contributors

dharnitski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sitecore.algolia's Issues

indexer is sent old items

When using a onPublishEndAsync strategy after I publish an item it gets updated correctly in Algolia. Then after I publish another item both ids are sent to Update on line 193 in AlgoliaBaseIndex.cs. In the var indexableUniqueIds. It looks like they're both updated in Algolia. We have a lot of publishing so this gets out of hand quickly.

I tried to step through and debug. From what I can tell the Update function gets called from Sitecore so that function needs to check if an item was not send to Algolia yet. I looked in the history table and the timestamps are being updated correctly so I'm surprised the IDs are being sent to the function at all.

I'm on Sitecore.NET 8.2 (rev. 160729).

Thanks for any help.

Reference Computed field

Reference Fields store item Id(s). Algolis need to have names.

Success criteria:

  1. Field name is selectable

  2. By Default return Item name/dispaly name

  3. Return Array for multi select

  4. Allow to pick reference item field that will be used instead of "Display name"

Document crawling fails if Computed field name duplicates Item field name

ManagedPoolThread #6 15:27:29 WARN Crawler : AddRecursive DoItemAdd failed - {0C879602-EF9A-4B0F-B992-08F923F7AA90}
Exception: System.ArgumentException
Message: Can not add property professions to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.
Source: Newtonsoft.Json
at Newtonsoft.Json.Linq.JObject.ValidateToken(JToken o, JToken existing)
at Newtonsoft.Json.Linq.JContainer.InsertItem(Int32 index, JToken item, Boolean skipParentCheck)
at Newtonsoft.Json.Linq.JContainer.AddInternal(Int32 index, Object content, Boolean skipParentCheck)
at Score.ContentSearch.Algolia.AlgoliaDocumentBuilder.AddFieldAsEnumarable(String fieldName, Object fieldValue, Boolean append)
at Score.ContentSearch.Algolia.AlgoliaDocumentBuilder.AddField(String fieldName, Object fieldValue, Boolean append)
at Score.ContentSearch.Algolia.AlgoliaDocumentBuilder.AddComputedIndexFields()
at Score.ContentSearch.Algolia.AlgoliaIndexOperations.GetIndexData(IIndexable indexable, IProviderUpdateContext context)
at Score.ContentSearch.Algolia.AlgoliaIndexOperations.Add(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
at Sitecore.ContentSearch.SitecoreItemCrawler.DoAdd(IProviderUpdateContext context, SitecoreIndexableItem indexable)
at Sitecore.ContentSearch.HierarchicalDataCrawler1.CrawlItem(T indexable, IProviderUpdateContext context, CrawlState1 state)

Indexer should only sent in CD instance only

I have this Sitecore Instance Configuration
CD Instance for content delivery
CM Instance for content management, all of the sitecore's shell must always from this instance.

CD Instance have internet access to public
CM Instance have only intranet to access databases
We use index remoteBuild strategy to perform remote build, in other words whenever CM instance invoke build index, any other CD instances will perform build similar index.

For Sitecore.Algolia, I cannot find any config to limit updating index to algolia-api {api-id}--1.algolianet.com etc in CD Instance only, this causing error could not access algolia-api-url in CM instance

Edit:
This feature might be resolved by removing algolia's configurations in CM side, but still that way webmaster will not know there are algolia index in CD side

Implement AlgoliaBaseIndex.EnableFieldLanguageFallback

ManagedPoolThread #9 15:46:51 FATAL Could not add field {3749597E-F34D-4096-831E-1DBAC7181FD7} : cascaded placeholders for indexable sitecore://master/{845E7A47-0D93-4BC4-8D16-FE837D15D92E}?lang=en&ver=1
Exception: System.NotImplementedException
Message: The method or operation is not implemented.
Source: Score.ContentSearch.Algolia
   at Score.ContentSearch.Algolia.AlgoliaBaseIndex.get_EnableFieldLanguageFallback()
   at Sitecore.ContentSearch.AbstractDocumentBuilder`1.CheckAndAddField(IIndexable indexable, IIndexableDataField field)

Crawling fails if document is bigger than current quote

Job started: Index_Update_IndexName=algolia_test|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. ---> Algolia.Search.AlgoliaException: Record at the position 77 objectID=en_98774257-1d24-444f-b482-543ad3408e1c is too big size=445709 bytes. Contact us if you need an extended quota
at Algolia.Search.AlgoliaClient.d__58.MoveNext() in C:\prog\gitHub\sitecore-algolia\Algolia.Search\AlgoliaClient.cs:line 894
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Score.ContentSearch.Algolia.AlgoliaUpdateContext.b__6_1(IEnumerable1 chunk) in C:\prog\gitHub\sitecore-algolia\Score.ContentSearch.Algolia\AlgoliaUpdateContext.cs:line 61 at System.Collections.Generic.List1.ForEach(Action`1 action)
at Score.ContentSearch.Algolia.AlgoliaUpdateContext.Commit() in C:\prog\gitHub\sitecore-algolia\Score.ContentSearch.Algolia\AlgoliaUpdateContext.cs:line 62
at Score.ContentSearch.Algolia.AlgoliaBaseIndex.DoRebuild(IProviderUpdateContext context, IndexingOptions indexingOptions, CancellationToken cancellationToken) in C:\prog\gitHub\sitecore-algolia\Score.ContentSearch.Algolia\AlgoliaBaseIndex.cs:line 140
at Score.ContentSearch.Algolia.AlgoliaBaseIndex.PerformRebuild(IndexingOptions indexingOptions, CancellationToken cancellationToken) in C:\prog\gitHub\sitecore-algolia\Score.ContentSearch.Algolia\AlgoliaBaseIndex.cs:line 93
at Score.ContentSearch.Algolia.AlgoliaBaseIndex.Rebuild(IndexingOptions indexingOptions) in C:\prog\gitHub\sitecore-algolia\Score.ContentSearch.Algolia\AlgoliaBaseIndex.cs:line 119
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Jobs.Job.ThreadEntry(Object state)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.