Simple Unified Search

Vote:
 

Hi,

I've got a test index and have created a simple stand-alone project.

                     IClient client = Client.CreateFromConfig();

                     int nMaxResults = 50;

                    var dateRanges = new List()
                    {
                        new DateRange { From = DateTime.Now.AddDays(-1), To = DateTime.Now },
                        new DateRange { From = DateTime.Now.AddDays(-7), To = DateTime.Now.AddDays(-1) },
                        new DateRange { From = DateTime.Now.AddDays(-30), To = DateTime.Now.AddDays(-7) },
                        new DateRange { From = DateTime.Now.AddDays(-365), To = DateTime.Now.AddDays(-365) },
                        new DateRange { From = DateTime.Now.AddYears(-2), To = DateTime.Now.AddDays(-365) },
                    };

                    client.Conventions.UnifiedSearchRegistry.Add();

                   var searchResult = client.UnifiedSearchFor("Work", Language.English)
                            .Track()
                            .ApplyBestBets()
                            .Take(nMaxResults)
                            .RangeFacetFor(x => x.SearchPublishDate, dateRanges.ToArray())
                            .FilterFacet("PublishedDate", x => x.SearchPublishDate.InRange(new DateTime(1456790400), new DateTime(1459468800)))
                            .GetResult();

                    Console.WriteLine("There are " + searchResult.TotalMatching + " results");


When I run this I get the exception:

An exception of type 'StructureMap.StructureMapConfigurationException' occurred in StructureMap.dll but was not handled in user code

Additional information: No default Instance is registered and cannot be automatically determined for type 'EPiServer.Find.Framework.Statistics.IStatisticTagsHelper'

what am I doing wrong?

#146880
Mar 29, 2016 16:48
Vote:
 

Probably missing some structuremap configuration...it cant resolve the interface to a concrete class...

#146881
Edited, Mar 29, 2016 17:15
Vote:
 

and what does this involve.. in simple terms... 

#146882
Mar 29, 2016 17:16
Vote:
 

Start by checking that you have the assembly EPiServer.Find.Framework in bin folder of your project with correct version. And with a stand alone project...what are we talking about? I'm guessing this is the root of the problem. A lot of interface => concrete class mappings for EPiServer Find are configured out of the box if you let EPiServer handle that structure map configuration for you. If you have a separate project, like web api, unit test etc, you will need to set up that structure map resolving for yourself

#146883
Edited, Mar 29, 2016 17:38
Vote:
 

Thanks,

Do you know of any documentation which covers this? It's not clear from what I've seen here : http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/11/DotNET-Client-API/Client-class/

#146884
Mar 29, 2016 18:46
Vote:
 

What are you trying to do? maybe I can suggest an alternative approach?

#146885
Mar 29, 2016 20:28
Vote:
 

We're trying to use the Find product without necessarily requiring the use of the CRM system.

My understanding was that it should be possible but it seems to be quite tightly integrated. We're trying to strip it down to bare bones to learn how it works.

Thanks for any assistance.

Cheers

Gordon

#146886
Mar 29, 2016 20:34
Vote:
 

If you would like to use Find standalone, i.e. without CMS integration, then you should have only EPiServer.Find.dll in your bin folder and use only API available there. The core API does not need any StructureMap configuration.

There are two main assemblies responsible for integration with Episerver CMS: EPiServer.Find.Cms and EPiServer.Find.Framework. The ApplyBestBets() extension method is from EPiServer.Find.Framework assembly which requires StructureMap initialization and setup.

#146895
Mar 30, 2016 10:41
Vote:
 

Thanks, 

Does this mean we can't use Track() in standalone mode?

#146898
Mar 30, 2016 11:00
Vote:
 

Technically, it might work if you add a reference to EPiServer.Find.Statistics assembly, but semantically its a part of CMS integration.

#146899
Mar 30, 2016 11:10
Vote:
 

Unfortunately I get the same exception with just .Track().

Is there any documentation on how I can setup structuremaps?

Thanks

#146910
Mar 30, 2016 15:59
Vote:
 

Try to use .StatisticsTrack() extension method from EPiServer.Find.Statistics namespace and make sure you do not refer to EPiServer.Find.Framework.dll in your project. 

#146914
Mar 30, 2016 17:07
Vote:
 

Hi Sergil,

Which assembly contains EPiServer.Find.Statistics?

Thanks

#147018
Apr 04, 2016 14:59
Vote:
 

Hello.
It's in EPiServer.Find.Statistics.dll, which you can find in EPiServer.Find.Cms NuGet package. You will need to extract this assembly from the NuGet package (just unzip it) and add a reference to it to your project. Do not install the package into your project - this will bring CMS and Framework dependencies that you want to avoid. 

#147019
Apr 04, 2016 15:29
Vote:
 

Thanks,

I've done that and can call it without it a runtime error. Unfortunately it doesn't seem to work, if I track it through fidder I can see an extra call being made to the javascript endpoint:

_search?search_type=count

The endpoint responds with :

 

HTTP/1.1 408 Request body incomplete

Date: Mon, 04 Apr 2016 15:33:02 GMT

Content-Type: text/html; charset=UTF-8

Connection: close

Cache-Control: no-cache, must-revalidate

Timestamp: 16:33:02.617

 

The request body did not contain the specified number of bytes. Got 0, expected 138                                                                                                                                                                                                                                                                                                                                                                                                                                             

#147109
Apr 06, 2016 12:43
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.