none
Building ContextObject From Programming RRS feed

  • Question

  • I am trying to build a contextobject from C# Till Now I am able to create a empty context object and using context modifier ImsSearch but I am unable to add it to context.

     Context ctx = new Microsoft.Ceres.InteractionEngine.Services.Context();
     ImsTermsOperator tm = new ImsTermsOperator();
                tm.Terms = "FSIS";
    ImsSearch ims = new ImsSearch("mysearch");

    How to add it to context object.

    It will be really helpful if we have documentation around using these  API with example.

     

    Thursday, November 17, 2011 5:06 PM

Answers

  • string xmlString = @"<?xml version='1.0' encoding='utf-8' standalone='yes'?>
                                    <context xmlns:context='http://schemas.microsoft.com/ceres/interaction/2010/03/context' xmlns='http://schemas.microsoft.com/ceres/interaction/2010/03/context' xmlns:ims='http://schemas.microsoft.com/ceres/interaction/2010/03/ims'>
                                    <routing><site></site><page></page><panel></panel><flowName>NameOfIMSFlow</flowName><revision></revision><nodeSetName></nodeSetName><preprocessingFlow></preprocessingFlow></routing>
                                    <imsSearch xmlns='http://schemas.microsoft.com/ceres/interaction/2010/03/ims' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
                                      <search>
                                      <_collapsing />
                                      <_freshnessBoost />
                                      <_locale>en-US</_locale>
                                      <_navigation />
                                      <_clusters />
                                      <_qtPipeline />
                                      <_resubmit />
                                      <_resultView />
                                      <_rpPipeline />
                                      <_spellCheckType>0</_spellCheckType>
                                      <_timeout>0</_timeout>
                                      <_searchOperator xsi:type='TermsOperator'>
                                      <_scopes />
                                      <_source />
                                      <_returnScope />
                                      <_terms>sample search</_terms>
                                      <_weight>100</_weight>
                                      <_linguistics>true</_linguistics>
                                      <_mode>0</_mode>
                                      </_searchOperator>
                                      <_sortElements />
                                      <_additionalParameters />
                                      </search>
                                      <offset>0</offset>
                                      <count>10</count>
                                      <navigation />
                                      <findsimilar />
                                      <docsonly>false</docsonly>
                                      </imsSearch></context>";

                using (XmlReader reader = XmlReader.Create(new StringReader(xmlString)))
                {
                    Context ctx = Context.Load(reader);                

                    RequestInfo Reqinfo = ctx.CreateRequest();
                    Reqinfo.IsAnonymous = true;
                    Reqinfo.SessionId = "session";
                    Reqinfo.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3; .NET4.0C; .NET4.0E)";
                    Reqinfo.ClientIP = "127.0.0.1";
                    Reqinfo.UserLanguage = "en-us";
                    Reqinfo.UserToken = "token"
                   
                    ProcessingEngineClient pec = new ProcessingEngineClient("Interaction NODE", 17047);
                    Context results = pec.ExecuteFlow(ctx);
                }
                

    Must be the interaction node engine + 5.

    • Marked as answer by Harvail Friday, January 20, 2012 5:08 PM
    Friday, January 13, 2012 3:13 AM

All replies

  • Hello,

    In terms of documentation the schema for the IMS context object are provided on your server where you installed the FAST Search Designer in the following default directory:

    C:\Program Files (x86)\FAST Search Server 2010 for Internet Sites\FAST Search Designer\Xml\Schemas

    There isn't really much provided by way of examples beyond the sample provided in the "FSIS 1.0 Documentation 2.0.6" guide in the 'Reference information' section. 

    It might actually be easier to enable debugging on the  and breakpoints in an IMS flow so you can examine the ContextObject that is automatically created when using one of the IMS UI Toolkit sample search UIs.  If you have any questions on that take a look at the 'How to debug an IMS flow' procedure starting on page 110 of the guide. 

    Regards,

    Jason Greene

    Thursday, November 17, 2011 6:16 PM
  • string xmlString = @"<?xml version='1.0' encoding='utf-8' standalone='yes'?>
                                    <context xmlns:context='http://schemas.microsoft.com/ceres/interaction/2010/03/context' xmlns='http://schemas.microsoft.com/ceres/interaction/2010/03/context' xmlns:ims='http://schemas.microsoft.com/ceres/interaction/2010/03/ims'>
                                    <routing><site></site><page></page><panel></panel><flowName>NameOfIMSFlow</flowName><revision></revision><nodeSetName></nodeSetName><preprocessingFlow></preprocessingFlow></routing>
                                    <imsSearch xmlns='http://schemas.microsoft.com/ceres/interaction/2010/03/ims' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
                                      <search>
                                      <_collapsing />
                                      <_freshnessBoost />
                                      <_locale>en-US</_locale>
                                      <_navigation />
                                      <_clusters />
                                      <_qtPipeline />
                                      <_resubmit />
                                      <_resultView />
                                      <_rpPipeline />
                                      <_spellCheckType>0</_spellCheckType>
                                      <_timeout>0</_timeout>
                                      <_searchOperator xsi:type='TermsOperator'>
                                      <_scopes />
                                      <_source />
                                      <_returnScope />
                                      <_terms>sample search</_terms>
                                      <_weight>100</_weight>
                                      <_linguistics>true</_linguistics>
                                      <_mode>0</_mode>
                                      </_searchOperator>
                                      <_sortElements />
                                      <_additionalParameters />
                                      </search>
                                      <offset>0</offset>
                                      <count>10</count>
                                      <navigation />
                                      <findsimilar />
                                      <docsonly>false</docsonly>
                                      </imsSearch></context>";

                using (XmlReader reader = XmlReader.Create(new StringReader(xmlString)))
                {
                    Context ctx = Context.Load(reader);                

                    RequestInfo Reqinfo = ctx.CreateRequest();
                    Reqinfo.IsAnonymous = true;
                    Reqinfo.SessionId = "session";
                    Reqinfo.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3; .NET4.0C; .NET4.0E)";
                    Reqinfo.ClientIP = "127.0.0.1";
                    Reqinfo.UserLanguage = "en-us";
                    Reqinfo.UserToken = "token"
                   
                    ProcessingEngineClient pec = new ProcessingEngineClient("Interaction NODE", 17047);
                    Context results = pec.ExecuteFlow(ctx);
                }
                

    Must be the interaction node engine + 5.

    • Marked as answer by Harvail Friday, January 20, 2012 5:08 PM
    Friday, January 13, 2012 3:13 AM