protected override ApiController CreateController(Type controllerType, HttpRequestMessage msg, UmbracoHelper helper, ITypedPublishedContentQuery qry, ServiceContext serviceContext, BaseSearchProvider searchProvider)
        {
            _onServicesCreated(msg, helper.UmbracoContext, qry, serviceContext, searchProvider);

            //Create the controller with all dependencies
            var ctor = controllerType.GetConstructor(new[]
                {
                    typeof(UmbracoContext),
                    typeof(UmbracoHelper),
                    typeof(BaseSearchProvider)
                });

            if (ctor == null)
            {
                throw new MethodAccessException("Could not find the required constructor for the controller");
            }

            var created = (ApiController)ctor.Invoke(new object[]
                    {
                        //ctor args
                        helper.UmbracoContext,
                        helper,
                        searchProvider
                    });

            return created;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            InitLookUpDictionary();

            //Check we have a search term
            var orgSearchTerm = Request.QueryString["q"].Trim();
            searchTerm = orgSearchTerm.Replace(" OR ", " ").Replace(" or ", " ");
            if (string.IsNullOrEmpty(searchTerm) || searchTerm.Length == 1)
            {
                phNotValid.Visible = true;
                phResults.Visible = false;
                return;
            }

            Searcher = ExamineManager.Instance.SearchProviderCollection["MultiIndexSearcher"];

            //Search Criteria for WIKI & Projects
            bool andSearch = false;
            var searchCriteria = Searcher.CreateSearchCriteria(BooleanOperation.Or);
            if (searchTerm.IndexOf("\"") == -1 && searchTerm.ToLower().IndexOf(" and ") > -1)
            {
                andSearch = true;
                searchTerm = searchTerm.Replace(" and ", " ").Replace(" AND ", " ");
            }

            /*var searchFilter = searchCriteria.Field("a","b").Or().GroupedOr
               .GroupedOr(new string[] { "nodeName", "bodyText", "description", "Title", "Body", "CommentsContent" }, searchTerm)
               .Compile();*/

            var searchQuery = searchTerm.BuildExamineString(10, "nodeName", andSearch);
            searchQuery += searchTerm.BuildExamineString(8, "bodyText", andSearch);
            searchQuery += searchTerm.BuildExamineString(9, "description", andSearch);
            searchQuery += searchTerm.BuildExamineString(10, "Title", andSearch);
            searchQuery += searchTerm.BuildExamineString(8, "Body", andSearch);
            searchQuery += searchTerm.BuildExamineString(7, "CommentsContent", andSearch).TrimEnd(' ');

            var searchFilter = searchCriteria.RawQuery(searchQuery);

            searchResults = Searcher.Search(searchFilter).OrderByDescending(x => x.Score);

            // set the searchterm back for the results view
            searchTerm = orgSearchTerm;

            //Get where to search (content)
            string searchWhere = Request.QueryString["content"];

            searchResults = FilterOnContentType(searchWhere, searchResults);

            BindResultsAndSetUpPaging(searchResults);
        }
Exemplo n.º 3
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            //var bootManager = new WebBootManager();
            //bootManager.Initialize();

            _customerIndexer = (CustomerIndexer)ExamineManager.Instance.IndexProviderCollection["MerchelloCustomerIndexer"];
            _searcher = ExamineManager.Instance.SearchProviderCollection["MerchelloCustomerSearcher"];

            _customerService = PreTestDataWorker.CustomerService;

            CustomerService.Created += CustomerServiceCreated;
            CustomerService.Saved += CustomerServiceSaved;
            CustomerService.Deleted += CustomerServiceDeleted;
        }
Exemplo n.º 4
0
        private void Activator(HttpRequestMessage httpRequestMessage, UmbracoContext umbracoContext, ITypedPublishedContentQuery arg3, ServiceContext serviceContext, BaseSearchProvider searchProvider)
        {
            _activator(httpRequestMessage, umbracoContext, arg3, serviceContext, searchProvider);

            Mapper.Initialize(configuration =>
            {
                var contentRepresentationMapper = new ContentModelMapper();
                contentRepresentationMapper.ConfigureMappings(configuration, umbracoContext.Application);

                var mediaRepresentationMapper = new MediaModelMapper();
                mediaRepresentationMapper.ConfigureMappings(configuration, umbracoContext.Application);

                var memberRepresentationMapper = new MemberModelMapper();
                memberRepresentationMapper.ConfigureMappings(configuration, umbracoContext.Application);

                var relationRepresentationMapper = new RelationModelMapper();
                relationRepresentationMapper.ConfigureMappings(configuration, umbracoContext.Application);
            });
        }
Exemplo n.º 5
0
 static SearchService()
 {
     _umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     _videoItemSearcher = ExamineManager.Instance.SearchProviderCollection["VideoItemSearcher"];
 }
Exemplo n.º 6
0
 /// <summary>
 /// Ensures the provider.
 /// </summary>
 /// <param name="p">The provider.</param>
 private static void EnsureProvider(BaseSearchProvider p)
 {
     if (!(p is LuceneSearcher))
     {
         throw new NotSupportedException("XSLT Extensions are only support for providers of type LuceneSearcher");
     }
 }
	    /// <summary>
	    /// Generally used for unit testing to use an explicit examine searcher
	    /// </summary>
	    /// <param name="searchProvider"></param>
	    /// <param name="indexProvider"></param>
	    internal DefaultPublishedMediaStore(BaseSearchProvider searchProvider, BaseIndexProvider indexProvider)
		{
		    _searchProvider = searchProvider;
		    _indexProvider = indexProvider;
		}
Exemplo n.º 8
0
 /// <summary>
 /// Internal constructor used for unit tests
 /// </summary>
 /// <param name="result"></param>
 /// <param name="indexer"></param>
 /// <param name="searcher"></param>
 internal ExamineBackedMedia(SearchResult result, BaseIndexProvider indexer, BaseSearchProvider searcher)
     : this(result)
 {
     _indexer = indexer;
     _searcher = searcher;
 }
        /// <summary>
        /// Searhes content
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="searchProvider"></param>
        /// <returns></returns>
        public IEnumerable <IPublishedContent> TypedSearch(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null)
        {
            var total = 0;

            return(TypedSearch(0, 0, out total, criteria, searchProvider));
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Check we have a search term
            var orgSearchTerm = Request.QueryString["q"].Trim();
            searchTerm = orgSearchTerm.Replace(" OR ", " ").Replace(" or ", " ");
            if (string.IsNullOrEmpty(searchTerm) || searchTerm.Length == 1)
            {
                phNotValid.Visible = true;
                phResults.Visible = false;
                return;
            }

            Searcher = ExamineManager.Instance.SearchProviderCollection["MultiIndexSearcher"];

            //Search Criteria for WIKI & Projects
            bool andSearch = false;
            var searchCriteria = Searcher.CreateSearchCriteria(BooleanOperation.Or);
            if (searchTerm.IndexOf("\"") == -1 && searchTerm.ToLower().IndexOf(" and ") > -1)
            {
                andSearch = true;
                searchTerm = searchTerm.Replace(" and ", " ").Replace(" AND ", " ");
            }

            /*var searchFilter = searchCriteria.Field("a","b").Or().GroupedOr
               .GroupedOr(new string[] { "nodeName", "bodyText", "description", "Title", "Body", "CommentsContent" }, searchTerm)
               .Compile();*/

            var searchQuery = searchTerm.BuildExamineString(10, "nodeName", andSearch);
            searchQuery += searchTerm.BuildExamineString(8, "bodyText", andSearch);
            searchQuery += searchTerm.BuildExamineString(9, "description", andSearch);
            searchQuery += searchTerm.BuildExamineString(10, "Title", andSearch);
            searchQuery += searchTerm.BuildExamineString(8, "Body", andSearch);
            searchQuery += searchTerm.BuildExamineString(7, "CommentsContent", andSearch).TrimEnd(' ');

            var searchFilter = searchCriteria.RawQuery(searchQuery);

            searchResults = Searcher.Search(searchFilter).OrderByDescending(x => x.Score);

            // set the searchterm back for the results view
            searchTerm = orgSearchTerm;

            //Get where to search (content)
            string searchWhere = Request.QueryString["content"];
            if (searchWhere.Contains("wiki") && !searchWhere.Contains("project") && !searchWhere.Contains("forum"))
            {
                //only wiki
                searchResults = from r in searchResults where r["__IndexType"] == "content" && r["nodeTypeAlias"] == "WikiPage" select r;
            }
            else if (!searchWhere.Contains("wiki") && searchWhere.Contains("project") && !searchWhere.Contains("forum"))
            {
                //only projects
                searchResults = from r in searchResults where r["__IndexType"] == "content" && (r["nodeTypeAlias"] == "Project" && r["projectLive"] == "1") select r;
            }
            else if (!searchWhere.Contains("wiki") && !searchWhere.Contains("project") && searchWhere.Contains("forum"))
            {
                //only forum
                searchResults = from r in searchResults where r["__IndexType"] == "documents" select r;
            }
            else if (searchWhere.Contains("wiki") && searchWhere.Contains("project") && !searchWhere.Contains("forum"))
            {
                //wiki and projects
                searchResults = from r in searchResults where r["__IndexType"] == "content" && (r["nodeTypeAlias"] == "WikiPage" || (r["nodeTypeAlias"] == "Project" && r["projectLive"] == "1")) select r;
            }
            else if (searchWhere.Contains("wiki") && !searchWhere.Contains("project") && searchWhere.Contains("forum"))
            {
                //wiki and forum
                searchResults = from r in searchResults where r["__IndexType"] == "documents" || r["nodeTypeAlias"] == "WikiPage" select r;
            }
            else if (!searchWhere.Contains("wiki") && searchWhere.Contains("project") && searchWhere.Contains("forum"))
            {
                //project and forum
                searchResults = from r in searchResults where r["__IndexType"] == "documents" || (r["nodeTypeAlias"] == "Project" && r["projectLive"] == "1") select r;
            }
            else
            {
                searchResults = from r in searchResults where r["__IndexType"] == "documents" || r["nodeTypeAlias"] == "WikiPage" || (r["nodeTypeAlias"] == "Project" && r["projectLive"] == "1") select r;
            }

            //Setup paging. If there isn't a page specified default to page 0
            int page = 0;
            int.TryParse(Request.QueryString["p"], out page);
            int ItemsPerPage = 20;

            //Bind repater to the list of results
            searchResultListing.DataSource = searchResults.Skip(page * ItemsPerPage).Take(ItemsPerPage);
            searchResultListing.DataBind();

            //Page numbering...
            int numberOfResults = searchResults.Count();
            int numberOfPages = (int)Math.Round((float)numberOfResults / (float)ItemsPerPage, 0);

            if (numberOfPages > 1)
            {
                //Lets generate the HTML string up for the pager....
                pager.Text = "<div><strong>Pages:</strong></div><ul class=\"deliPaging\">";

                for (int i = 0; i < numberOfPages; i++)
                {
                    pager.Text += "<li>";

                    if (page == i)
                        pager.Text += "<a href='?q=" + searchTerm + "&content=" + Request.QueryString["content"] + "&p=" + i + "' class='selected'>";
                    else
                        pager.Text += "<a href='?q=" + searchTerm + "&content=" + Request.QueryString["content"] + "&p=" + i + "'>";

                    pager.Text += i + 1;
                    pager.Text += "</a>";
                    pager.Text += "</li>";
                }

                pager.Text += "</ul>";
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Before any of the index/search collections are accessed, the providers need to be loaded
        /// </summary>
        private void EnsureProviders()
        {
            if (!_providersInit)
            {
                lock (_lock)
                {
                    // Do this again to make sure _provider is still null
                    if (!_providersInit)
                    {
                        // Load registered providers and point _provider to the default provider	

                        _indexProviderCollection = new IndexProviderCollection();
                        ProvidersHelper.InstantiateProviders(ExamineSettings.Instance.IndexProviders.Providers, _indexProviderCollection, typeof(BaseIndexProvider));

                        _searchProviderCollection = new SearchProviderCollection();
                        ProvidersHelper.InstantiateProviders(ExamineSettings.Instance.SearchProviders.Providers, _searchProviderCollection, typeof(BaseSearchProvider));

                        //set the default
                        if (!string.IsNullOrEmpty(ExamineSettings.Instance.SearchProviders.DefaultProvider))
                            _defaultSearchProvider = _searchProviderCollection[ExamineSettings.Instance.SearchProviders.DefaultProvider];

                        if (_defaultSearchProvider == null)
                            throw new ProviderException("Unable to load default search provider");

                        _providersInit = true;


                        //check if we need to rebuild on startup
                        if (ExamineSettings.Instance.RebuildOnAppStart)
                        {
                            foreach (var index in _indexProviderCollection.Cast<IIndexer>())
                            {
                                if (!index.IndexExists())
                                {
                                    var args = new BuildingEmptyIndexOnStartupEventArgs(index);
                                    OnBuildingEmptyIndexOnStartup(args);
                                    if (!args.Cancel)
                                    {
                                        index.RebuildIndex();    
                                    }
                                }
                            }    
                        }

                    }
                }
            }
        }
Exemplo n.º 12
0
	    /// <summary>
	    /// Generally used for unit testing to use an explicit examine searcher
	    /// </summary>
	    /// <param name="searchProvider"></param>
	    /// <param name="indexProvider"></param>
	    internal PublishedMediaCache(BaseSearchProvider searchProvider, BaseIndexProvider indexProvider)
	    {
		    _searchProvider = searchProvider;
		    _indexProvider = indexProvider;
		}
 protected abstract ApiController CreateController(Type controllerType, HttpRequestMessage msg, UmbracoHelper helper, ITypedPublishedContentQuery qry, ServiceContext serviceContext, BaseSearchProvider searchProvider);
Exemplo n.º 14
0
        /// <summary>
        /// Creates a base search criteria for getting posts.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="searcher"></param>
        /// <returns></returns>
        protected ISearchCriteria GetPostBaseCriteria(IPublishedContent node, BaseSearchProvider searcher)
        {
            var landing = DataService.Instance.GetLanding(node);

            var criteria = searcher.CreateSearchCriteria(IndexTypes.Content);
            criteria.Field("nodeTypeAlias", "uBlogsyPost")
                    .And()
                    .Field(uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchablePath, landing.Id.ToString())
                    .Not()
                    .Field("umbracoNaviHide", "1");

            return criteria;
        }