Beispiel #1
0
        private IQueryable <TResult> GetSolrQueryable <TResult>(SolrSearchContext context, IExecutionContext[] executionContext)
            where TResult : IStandardTemplateItem
        {
            var linqToSolrIndex = new SynthesisLinqToSolrIndex <TResult>(context, executionContext);

            if (context.Index.Locator.GetInstance <IContentSearchConfigurationSettings>().EnableSearchDebug())
            {
                ((IHasTraceWriter)linqToSolrIndex).TraceWriter = new LoggingTraceWriter(SearchLog.Log);
            }
            return(linqToSolrIndex.GetQueryable());
        }
        public LinqToSolrIndexWithSpatial(SolrSearchContext context, IExecutionContext[] executionContexts) : base(context, executionContexts)
        {
            var parameters =
                new SolrIndexParameters(
                    context.Index.Configuration.IndexFieldStorageValueFormatter,
                    context.Index.Configuration.VirtualFieldProcessors,
                    context.Index.FieldNameTranslator, executionContexts,
                    context.Index.Configuration.FieldMap);

            this.queryMapper    = new SolrSpatialQueryMapper(parameters);
            this.queryOptimizer = new SpatialSolrQueryOptimizer();
        }
            public SolrSearchResults(SolrSearchContext context, SolrQueryResults <Dictionary <string, object> > searchResults, SelectMethod selectMethod, IEnumerable <IExecutionContext> executionContexts, IEnumerable <IFieldQueryTranslator> virtualFieldProcessors)
            {
                this._context = context;
                this._solrIndexConfiguration = (SolrIndexConfiguration)this._context.Index.Configuration;
                this._selectMethod           = selectMethod;
                this._virtualFieldProcessors = virtualFieldProcessors;
                this._executionContexts      = executionContexts;
                this._numberFound            = searchResults.NumFound;
                this._searchResults          = ApplySecurity(searchResults, context.SecurityOptions, ServiceLocator.ServiceProvider.GetService <BaseCorePipelineManager>(), context.Index.Locator.GetInstance <IAccessRight>(), ref this._numberFound);
                var executionContext = this._executionContexts != null?this._executionContexts.FirstOrDefault(c => c is OverrideExecutionContext <IIndexDocumentPropertyMapper <Dictionary <string, object> > >) as OverrideExecutionContext <IIndexDocumentPropertyMapper <Dictionary <string, object> > > : null;

                this._mapper = (executionContext != null ? executionContext.OverrideObject : null) ?? this._solrIndexConfiguration.IndexDocumentPropertyMapper;
            }
        public FacetLinqToSolrIndex(SolrSearchContext context, IExecutionContext executionContext)
            : base(context, executionContext)
        {
            Assert.ArgumentNotNull(context, "context");
            this._context  = context;
            this._settings = context.Index.Locator.GetInstance <ISettings>();
            this._contentSearchSettings = context.Index.Locator.GetInstance <IContentSearchConfigurationSettings>();
            var executionContext1 = this.Parameters.ExecutionContext as CultureExecutionContext;
            var culture           = executionContext1 == null?CultureInfo.GetCultureInfo(Settings.DefaultLanguage) : executionContext1.Culture;

            this._cultureCode = culture.TwoLetterISOLanguageName;
            ((SolrFieldNameTranslator)this.Parameters.FieldNameTranslator).AddCultureContext(culture);
            this.PublicFieldNameTranslator = this.FieldNameTranslator;
        }
        public LinqToSolrIndexExtended([NotNull] SolrSearchContext context, IExecutionContext[] executionContexts)
            : base(
                new SolrIndexParameters(
                    context.Index.Configuration.IndexFieldStorageValueFormatter,
                    context.Index.Configuration.VirtualFields,
                    context.Index.FieldNameTranslator,
                    executionContexts[0]))
        {
            Assert.ArgumentNotNull(context, "context");
            this.context = context;

            contentSearchSettings = context.Index.Locator.GetInstance <IContentSearchConfigurationSettings>();
            pipeline = context.Index.Locator.GetInstance <Sitecore.Abstractions.ICorePipeline>();

            var cultureExecutionContext = this.Parameters.ExecutionContexts.FirstOrDefault(c => c is CultureExecutionContext) as CultureExecutionContext;

            var culture = cultureExecutionContext == null
                               ? CultureInfo.GetCultureInfo(Settings.DefaultLanguage)
                               : cultureExecutionContext.Culture;

            this.cultureCode = culture.TwoLetterISOLanguageName;

            ((SolrFieldNameTranslator)this.Parameters.FieldNameTranslator).AddCultureContext(culture);

            var curType = this.context.Index.GetType();

            // TODO Check it e.g. when interfaces exist
            while (curType != typeof(Sitecore.ContentSearch.SolrProvider.SolrSearchIndex) && curType.BaseType != typeof(System.Object))
            {
                curType = curType.BaseType;
            }

            if (curType != typeof(Sitecore.ContentSearch.SolrProvider.SolrSearchIndex))
            {
                throw new InvalidOperationException("Can't get the SolrSearchIndex type...");
            }

            indexOperationsInfo = curType.GetProperty("SolrOperations", BindingFlags.Instance | BindingFlags.NonPublic);
        }
 public LinqToSolrIndexExtended([NotNull] SolrSearchContext context, IExecutionContext executionContext)
     : this(context, new[] { executionContext })
 {
 }
Beispiel #7
0
 public SynthesisLinqToSolrIndex(SolrSearchContext context, params IExecutionContext[] executionContexts)
     : base(context, executionContexts)
 {
     FieldNameTranslator = new SynthesisSolrFieldNameTranslator(context, context.Index.FieldNameTranslator);;
 }
Beispiel #8
0
 public SynthesisLinqToSolrIndex(SolrSearchContext context) : this(context, null)
 {
 }
 public LinqToSolrIndexWithSpatial(SolrSearchContext context, IExecutionContext executionContext)
     : this(context, new IExecutionContext[] { executionContext })
 {
 }
 private IQueryable <TResult> GetSolrQueryable <TResult>(SolrSearchContext context, IExecutionContext[] executionContext)
     where TResult : IStandardTemplateItem
 {
     context.Index.FieldNameTranslator = _fieldNameTranslator.GetFieldNameTranslator(context.Index);
     return(context.GetQueryable <TResult>(executionContext));
 }