Lucene Analyzers for Sitecore – how the tokenized content looks like?

Everyone who have worked with Lucene indexes in Sitecore probably asked one day  him self – “how my content looks after tokenization process?”.

The answer of course is different depending on the type of used analyzer. (About types of analyzers you can read here. I will not provide those information here because it is not in the scope of this post)

Few days ago one of my colleagues (Wojciech Urban – thanks for that!), found the very useful tool which provide us following information:

  1. how tokenized text looks like
  2. how get tokens which are equal to those inside Lucene index

< You can find this tool here >

How tokenized text looks like?

As you can see in the image you are able to insert any description and test the tokenization process results.

2016-03-26_17h08_40

You can also change types of analyzers – you can choose from the following list:

2016-03-26_17h11_13

With this tool, results of your queries would never surprise you again!

How to get tokens which are equal to those inside Lucene index?

If you need tokens – let say for do something with your search results you can do something like this:

// get the analyzer which you use
var analyzer = new StandardAnalyzer(Version.LUCENE_30);
// prepare StringReader object with your text inside
StringReader stringReader = new StringReader(text);
// get the tokens stream
TokenStream tokenStream = analyzer.TokenStream("defaultFieldName", stringReader);
while (tokenStream.IncrementToken())
   ITermAttribute termAtt = tokenStream.AddAttribute<ITermAttribute>();
   var term = termAtt.Term;
   // ...
   // ... do something with your term
   // ...
}

 

Sitecore with Solr – required configuration

In this post I will provide you some information about configuration of your Sitecore for work with Solr server.

Probably everyone who faced with that task, found the most popular and really good guide from sitecore-community.github.io (click).

But there is a one more thing which should be made. About this additional configuration I will write today.

We have to configure our Inversion of Control containers.

When we want to use Sitecore with Solr we have to configure at lease two inversion of control containers to work parallel. (Autofac and Windsor).

So lets do it!

Open your Global.asax.cs file and check your MvcApplication class definition – it should extend a WindsorApplication. So code will look in the following way:

public class MvcApplication : WindsorApplication

Ok, the next step is initialization code for your containers. This code should looks like:

public override void Application_Start()
        {            
            this.Container = (IWindsorContainer)new WindsorContainer();
            new WindsorSolrStartUp(this.Container).Initialize();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
 
            AutofacConfig.RegisterConfiguration();
        }

When you have your application configured in this way you may be sure that Sitecore tools (like administration panel) and communication with Solr server will work properly.

Well and the last but not least thing – check your Global.asax file – code inside it should look like:

<%@ Application Codebehind="Global.asax.cs" Inherits="<PROJECT_NAMESPACE>.MvcApplication" Language="C#" %>​

If you have any questions or problems, do not hesitate to ask or comment bellow the post.

 

Where can I download Sitecore?

Where can I download Sitecore?

Question from the title is very often asked question by everyone who wants to learn Sitecore.

The answer is very simple – you can not just download installer if you do not have Sitecore account with appropriate permissions.

So You probably want to know – how to get the account with appropriate permissions?

The answer is also simple. The only way to have account which has permissions to download Sitecore and Sitecore Modules is get account connected with company which is a Sitecore Partner.

In other words You have to work for someone who is a Sitecore Partner or just be a Sitecore Partner.

When you have appriopriate account you can visit two websites to download Sitecore.

For sitecore 6-7.5 you should visit sdn.sitecore.net

For Sitecore 8.0 – *.* you should visit dev.sitecore.net

Ok I’ve downloaded the Sitecore – can I install it?

No you can not. Sorry. The licence is required.

Licence for Sitecore is a XML file with licence data. You should be able to select path to the licence file during the installation process.

Licence is available to download only from spn.sitecore.net