/// <summary>
        /// Gets a queryable for Synthesis items
        /// </summary>
        /// <typeparam name="TResult">The type of the result item to bind to.</typeparam>
        /// <param name="context">The search context to use</param>
        /// <param name="applyStandardFilters">Controls whether results will be auto-filtered to context language, correct template, and latest version</param>
        /// <param name="executionContext">The execution context to run the query under</param>
        /// <returns>A queryable item that standard Sitecore LINQ can be used on</returns>
        public static IQueryable <TResult> GetSynthesisQueryable <TResult>(this IProviderSearchContext context, bool applyStandardFilters, params IExecutionContext[] executionContext)
            where TResult : IStandardTemplateItem
        {
            var args = new SynthesisSearchContextArgs
            {
                SearchContext    = context,
                ExecutionContext = executionContext
            };
            var result = QueryableResolver.Value.GetSynthesisQueryable <TResult>(args);

            if (applyStandardFilters)
            {
                result = result.ApplyStandardFilters();
            }
            return(result);
        }
        public IQueryable <TResult> GetSynthesisQueryable <TResult>(SynthesisSearchContextArgs args) where TResult : IStandardTemplateItem
        {
            Assert.IsNotNull(args, "Args must not be null");
            if (!(args.SearchContext is SolrSearchContext solrContext))
            {
                throw new NotImplementedException("A Solr index is not being used, if you're using Azure make sure that you're not overridding the synthesisSearchContext pipeline with the Solr processor");
            }

            var overrideMapper = new SynthesisSolrDocumentTypeMapper();

            overrideMapper.Initialize(args.SearchContext.Index);
            var mapperExecutionContext = new OverrideExecutionContext <IIndexDocumentPropertyMapper <Dictionary <string, object> > >(overrideMapper);
            var executionContexts      = new List <IExecutionContext>();

            if (args.ExecutionContext != null)
            {
                executionContexts.AddRange(args.ExecutionContext);
            }
            executionContexts.Add(mapperExecutionContext);
            return(GetSolrQueryable <TResult>(solrContext, executionContexts.ToArray()));
        }
        public IQueryable <TResult> GetSynthesisQueryable <TResult>(SynthesisSearchContextArgs args) where TResult : IStandardTemplateItem
        {
            Assert.IsNotNull(args, "Args must not be null");
            var luceneContext = args.SearchContext as LuceneSearchContext;

            if (luceneContext == null)
            {
                throw new NotImplementedException("A Lucene index is not being used, if you're using Solr make sure that you're overridding the synthesisSearchContext pipeline with the Solr processor in Synthesis.Solr");
            }

            var overrideMapper = new SynthesisLuceneDocumentTypeMapper();

            overrideMapper.Initialize(args.SearchContext.Index);

            var mapperExecutionContext = new OverrideExecutionContext <IIndexDocumentPropertyMapper <Document> >(overrideMapper);
            var executionContexts      = new List <IExecutionContext>();

            if (args.ExecutionContext != null)
            {
                executionContexts.AddRange(args.ExecutionContext);
            }
            executionContexts.Add(mapperExecutionContext);
            return(GetLuceneQueryable <TResult>(luceneContext, executionContexts.ToArray()));
        }
Exemple #4
0
 public IQueryable <TResult> GetSynthesisQueryable <TResult>(SynthesisSearchContextArgs args) where TResult : IStandardTemplateItem
 {
     throw new NotSupportedException("Lucene is no longer supported with Synthesis. To continue to use Content Search, please install Synthesis.Solr");
 }