Searching in multiple columns in Sitecore Ankiro Search

Sitecore Ankiro Search is a nightmare and a blessing. Once you have it going you have one of the most advanced search engines available.

One of the cool features is that seperate fields of one Sitecore template can be indexed seperately. This gives you an execllent method to index metadata along with your contents.

But what if you wish to search for one sentence in one field and another sentence in another field? Well, you’ll need some c# code for that. Use the SearchBuilder. With the SearchBuilder you construct your search query before you execute the search. In this example I construct my SearchBuilder and searches for “a” in column “Title” and “b” in column “Text”:

using Sitecore.Ankiro.Search;
using Sitecore.Ankiro.Search.SearchConstruction;

SearchBuilder builder = SearchFactory.Instance.CreateSearchBuilder("MyIndex");
SearchOperatorNode andOperator = builder.CreateOperatorNode(ESearchOperation.AndOperation);
SearchNode searchNode1 = builder.CreateIndexColumnsSearchNode("a", EPropertyInterpretation.Normal, 1.0, 0.8, "MyIndex", "Title");
SearchNode searchNode2 = builder.CreateIndexColumnsSearchNode("b",
EPropertyInterpretation.Normal, 1.0, 0.8, "MyIndex", "Text");
builder.RootNode = andOperator;
System.Xml.XmlDocument doc = SearchFactory.Instance.ExecuteSearch("", builder, 10, 0);

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in Sitecore 5 and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s