private static List <string> GetIndexedEntityLogicalNames(ICrmEntityIndex index) { var logicalNames = new List <string>(); try { using (var reader = IndexReader.Open(index.Directory, true)) using (var terms = reader.Terms(new Term(index.LogicalNameFieldName))) { while (terms.Term.Field == index.LogicalNameFieldName) { logicalNames.Add(terms.Term.Text); if (!terms.Next()) { break; } } } } catch (Exception e) { SearchEventSource.Log.ReadError(e); return(logicalNames); } return(logicalNames); }
public FetchXmlIndexDocumentFactory(ICrmEntityIndex index, FetchXml fetchXml, string titleAttributeLogicalName, FetchXmlLocaleConfig localeConfig) { if (index == null) { throw new ArgumentNullException("index"); } if (fetchXml == null) { throw new ArgumentNullException("fetchXml"); } if (titleAttributeLogicalName == null) { throw new ArgumentNullException("titleAttributeLogicalName"); } if (localeConfig == null) { throw new ArgumentNullException("localeConfig"); } _index = index; _contentMapProvider = AdxstudioCrmConfigurationManager.CreateContentMapProvider(); _fetchXml = fetchXml; _titleAttributeLogicalName = titleAttributeLogicalName; _localeConfig = localeConfig; _dataContext = _index.DataContext; }
private static Query GetEntityQuery(ICrmEntityIndex index, string entityLogicalName, Guid id) { return(new BooleanQuery { { new TermQuery(new Term(index.LogicalNameFieldName, entityLogicalName)), Occur.MUST }, { new TermQuery(new Term(index.PrimaryKeyFieldName, id.ToString())), Occur.MUST } }); }
public CrmEntityIndexBuilder(ICrmEntityIndex index) { if (index == null) { throw new ArgumentNullException("index"); } _index = index; }
public ScopedIndexSearcher(ICrmEntityIndex index, IEnumerable <string> scopes) : base(index) { if (scopes == null) { throw new ArgumentNullException("scopes"); } _scopes = scopes; }
/// <summary> /// Gets a language-specific Lucene <see cref="Analyzer"/> for the current user context /// </summary> /// <param name="index">Current search index</param> /// <param name="isMultiLanguageEnabled">flag for multilanguage enabled portal</param> /// <param name="contextLanguage">website language</param> /// <returns>Language-specific analyzer if Multi Language is enabled. Default index analyzer otherwise</returns> public static Analyzer GetQuerySpecificAnalyzer(this ICrmEntityIndex index, bool isMultiLanguageEnabled, IWebsiteLanguage contextLanguage) { if (!isMultiLanguageEnabled || contextLanguage == null) { return(index.Analyzer); } return(CreateSpecificAnalyzer(contextLanguage.Lcid, index.Version)); }
public EntitySetUserQueryIndexer(ICrmEntityIndex index, string savedQueryName, string entityLogicalName, IEnumerable <Filter> filters = null, IEnumerable <Link> links = null) : base(index, savedQueryName) { if (string.IsNullOrEmpty(entityLogicalName)) { throw new ArgumentException("Can't be null or empty.", "entityLogicalName"); } EntityLogicalName = entityLogicalName; Filters = filters ?? Enumerable.Empty <Filter>(); Links = links ?? Enumerable.Empty <Link>(); }
protected override ICrmEntityIndexSearcher CreateIndexSearcher(ICrmEntityIndex index) { var websiteId = GetWebsiteId(); if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.PortalFacetedNavigation)) { return(new PortalFacetedIndexSearcher(index, websiteId)); } return(new PortalIndexSearcher(index, websiteId)); }
public CrmEntitySearchResultFactory(ICrmEntityIndex index, ICrmEntitySearchResultFragmentProvider fragmentProvider) { if (index == null) { throw new ArgumentNullException("index"); } if (fragmentProvider == null) { throw new ArgumentNullException("fragmentProvider"); } Index = index; FragmentProvider = fragmentProvider; }
public SavedQueryIndexer(ICrmEntityIndex index, string savedQueryName) { if (index == null) { throw new ArgumentNullException("index"); } if (string.IsNullOrEmpty(savedQueryName)) { throw new ArgumentException("Can't be null or empty.", "savedQueryName"); } Index = index; SavedQueryName = savedQueryName; _indexers = new Lazy <ICrmEntityIndexer[]>(GetIndexersForSavedQueries, LazyThreadSafetyMode.None); }
public SimpleHtmlHighlightedFragmentProvider(ICrmEntityIndex index, Query query) { if (index == null) { throw new ArgumentNullException("index"); } if (query == null) { throw new ArgumentNullException("query"); } _index = index; var queryScorer = new QueryScorer(query); _highlighter = new Highlighter(new SimpleHTMLFormatter(_highlighterStartTag, _highlighterEndTag), queryScorer) { TextFragmenter = new SimpleSpanFragmenter(queryScorer, 160) }; }
public CrmEntityIndexSearcher(ICrmEntityIndex index) { if (index == null) { throw new ArgumentNullException("index"); } _index = index; if (!IndexReader.IndexExists(_index.Directory)) { throw new IndexNotFoundException("Search index not found in {0}. Ensure index is constructed before attempting to search.".FormatWith(_index.Directory)); } var stopwatch = new Stopwatch(); stopwatch.Start(); _searcher = new IndexSearcher(_index.Directory, true); stopwatch.Stop(); ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Lucene IndexSearcher initialized ({0}ms)", stopwatch.ElapsedMilliseconds)); }
/// <summary> /// Initializes a new instance of the <see cref="PortalFacetedIndexSearcher"/> class. /// The portal faceted index searcher. /// </summary> /// <param name="index"> /// The index. /// </param> /// <param name="websiteID"> /// The website id. /// </param> public PortalFacetedIndexSearcher(ICrmEntityIndex index, Guid websiteID) : base(index, websiteID) { this.config = new FixedFacetsConfiguration(); // The facet engine requires you to define handlers (these just tell BoboBrowse how to handle // the field's data) and specs (these tell BoboBrowse how to return the facets during a search) // for each faceted field. Since our facets are preconfigured, we'll just maintain these in // the faceted searcher instance this.specs = new Dictionary <string, FacetSpec>(); var handlers = new List <IFacetHandler>(); foreach (var facetConfiguration in this.config.GetConfiguredFacets()) { if (facetConfiguration.FacetHandlerType == FacetHandlerType.Static) { handlers.Add(facetConfiguration.FacetHandler); } this.specs.Put(facetConfiguration.FieldName, facetConfiguration.Spec); } //// The BoboIndexReader is just a wrapper around the lucene IndexReader this.boboReader = BoboIndexReader.GetInstance(this.Searcher.IndexReader, handlers); }
internal FetchXmlIndexer(ICrmEntityIndex index, FetchXml fetchXml, string titleAttributeLogicalName) { if (index == null) { throw new ArgumentNullException("index"); } if (fetchXml == null) { throw new ArgumentNullException("fetchXml"); } if (titleAttributeLogicalName == null) { throw new ArgumentNullException("titleAttributeLogicalName"); } _index = index; _fetchXml = fetchXml; _titleAttributeLogicalName = titleAttributeLogicalName; if (!this._fetchXml.ContainsAttribute("modifiedon") && this._fetchXml.LogicalName != "annotation") { this._fetchXml.AddAttribute("modifiedon"); } if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching)) { if (this._fetchXml.LogicalName == "adx_blog") { if (!this._fetchXml.ContainsAttribute("adx_parentpageid")) { this._fetchXml.AddAttribute("adx_parentpageid"); } } if (this._fetchXml.LogicalName == "adx_blogpost") { if (!this._fetchXml.ContainsAttribute("adx_blogid")) { this._fetchXml.AddAttribute("adx_blogid"); } // Add the published attribute as we need it for indexing for CMS if (!this._fetchXml.ContainsAttribute("adx_published")) { this._fetchXml.AddAttribute("adx_published"); } if (!this._fetchXml.ContainsLinkEntity("adx_blog_blogpost")) { this._fetchXml.AddLinkEntity("adx_blog", "adx_blogid", "adx_blogid", "adx_blog_blogpost", "inner"); } this._fetchXml.AddLinkEntityAttribute("adx_blog_blogpost", "adx_parentpageid"); this._fetchXml.AddLinkEntityAttribute("adx_blog_blogpost", "adx_partialurl"); if (!this._fetchXml.ContainsAttribute("adx_partialurl")) { this._fetchXml.AddAttribute("adx_partialurl"); } } if (this._fetchXml.LogicalName == "adx_idea") { if (!this._fetchXml.ContainsAttribute("adx_ideaforumid")) { this._fetchXml.AddAttribute("adx_ideaforumid"); } // Add the approved flag as this is needed for indexing CMS this._fetchXml.AddConditionalStatement("and", "adx_approved", "eq", "true"); if (!this._fetchXml.ContainsLinkEntity("adx_idea_ideaforum")) { this._fetchXml.AddLinkEntity("adx_ideaforum", "adx_ideaforumid", "adx_ideaforumid", "adx_idea_ideaforum", "inner"); } this._fetchXml.AddLinkEntityAttribute("adx_idea_ideaforum", "adx_partialurl"); this._fetchXml.AddConditionalStatement("and", "adx_partialurl", "not-null", null, "adx_idea_ideaforum"); this._fetchXml.AddConditionalStatement("and", "adx_partialurl", "not-null"); this._fetchXml.AddAttribute("adx_partialurl"); } if (this._fetchXml.LogicalName == "adx_communityforumthread") { if (!this._fetchXml.ContainsAttribute("adx_forumid")) { this._fetchXml.AddAttribute("adx_forumid"); } } if (this._fetchXml.LogicalName == "adx_communityforumpost") { if (!this._fetchXml.ContainsLinkEntity("adx_communityforumpost_communityforumthread")) { this._fetchXml.AddLinkEntity("adx_communityforumthread", "adx_communityforumthreadid", "adx_forumthreadid", "adx_communityforumpost_communityforumthread", "inner"); } this._fetchXml.AddLinkEntityAttribute("adx_communityforumpost_communityforumthread", "adx_forumid"); } if (this._fetchXml.LogicalName == "adx_webfile") { if (!this._fetchXml.ContainsAttribute("adx_parentpageid")) { this._fetchXml.AddAttribute("adx_parentpageid"); } if (!this._fetchXml.ContainsAttribute("adx_partialurl")) { this._fetchXml.AddAttribute("adx_partialurl"); } } if (this._fetchXml.LogicalName == "incident") { // It is marked as Resolved (1) this._fetchXml.AddConditionalStatement("and", "statecode", "eq", "1"); this._fetchXml.AddConditionalStatement("and", "adx_publishtoweb", "eq", "1"); } // CMS filtering for KnowledgeArticles if they don't have these rules then don't add to index. if (this._fetchXml.LogicalName == "knowledgearticle") { // make sure statecode is published = 3 this._fetchXml.AddConditionalStatement("and", "statecode", "eq", "3"); this._fetchXml.AddConditionalStatement("and", "isrootarticle", "eq", "false"); this._fetchXml.AddConditionalStatement("and", "isinternal", "eq", "false"); // Add this filter for url filtering this._fetchXml.AddConditionalStatement("and", "articlepublicnumber", "not-null"); this.AddRelatedEntityFetch("connection", "connectionid", "record1id", "knowledgearticleid", "record2id", "product", "productid", "record2id", "productid"); if (this._index.DataContext.AssertEntityExists("adx_contentaccesslevel")) { this.AddRelatedEntityFetch("adx_knowledgearticlecontentaccesslevel", "adx_knowledgearticlecontentaccesslevelid", "knowledgearticleid", "knowledgearticleid", "adx_contentaccesslevelid", "adx_contentaccesslevel", "adx_contentaccesslevelid", "adx_contentaccesslevelid", "adx_contentaccesslevelid"); } } } // Add the language fields since the related fields cannot be included in a view using the savedquery editor if (_fetchXml.LogicalName == "knowledgearticle") { _fetchXml.AddLinkEntity("languagelocale", "languagelocaleid", "languagelocaleid", "language_localeid", "outer"); _fetchXml.AddLinkEntityAttribute("language_localeid", "localeid"); _fetchXml.AddLinkEntityAttribute("language_localeid", "code"); _fetchXml.AddLinkEntityAttribute("language_localeid", "region"); _fetchXml.AddLinkEntityAttribute("language_localeid", "name"); _fetchXml.AddLinkEntityAttribute("language_localeid", "language"); // This ensures we get knowledge article search result along with annotation in case knowledge article doesn't have keywords contained in annotation if (_index.DisplayNotes) { this.AddNotesLinkEntity(_index.NotesFilter); } _localeConfig = FetchXmlLocaleConfig.CreateKnowledgeArticleConfig(); } else { _localeConfig = FetchXmlLocaleConfig.CreatePortalLanguageConfig(); } if (_fetchXml.LogicalName == "annotation") { _fetchXml.AddConditionalStatement("and", "filename", "not-null"); this.AddNotesFilter(_index.NotesFilter); this.AddRelatedKnowledgeArticleAndProductFetch(); } }
public FetchXmlIndexer(ICrmEntityIndex index, XNode fetchXml, string titleAttributeLogicalName) : this(index, new FetchXml(fetchXml), titleAttributeLogicalName) { }
public FetchXmlIndexer(ICrmEntityIndex index, string fetchXml, string titleAttributeLogicalName) : this(index, XDocument.Parse(fetchXml), titleAttributeLogicalName) { }
protected void RefreshSearcher(ICrmEntityIndex index) { _searcherPool.Refresh(GetIndexSearcherName(index)); }
protected override string GetIndexSearcherName(ICrmEntityIndex index) { var websiteId = GetWebsiteId(); return("{0}:{1}:{2}".FormatWith(index.Name, index.Directory, websiteId)); }
protected virtual ICrmEntityIndexSearcher CreateIndexSearcher(ICrmEntityIndex index) { return(new CrmEntityIndexSearcher(index)); }
protected virtual string GetIndexSearcherName(ICrmEntityIndex index) { return("{0}:{1}".FormatWith(index.Name, index.Directory)); }
public PortalSearchResultFactory(string portalName, ICrmEntityIndex index, ICrmEntitySearchResultFragmentProvider fragmentProvider) : base(index, fragmentProvider) { PortalName = portalName; }
public ScopedQueryIndexSearcher(ICrmEntityIndex index) : base(index) { }
public PortalIndexSearcher(ICrmEntityIndex index, Guid websiteID) : base(index, websiteID.ToString()) { }
public SingleEntitySavedQueryIndexer(ICrmEntityIndex index, string savedQueryName, string entityLogicalName, Guid id) : base(index, savedQueryName, entityLogicalName) { _id = id; }
public ScopedIndexSearcher(ICrmEntityIndex index, params string[] scopes) : this(index, scopes as IEnumerable <string>) { }
/// <summary> /// Gets a language-specific Lucene <see cref="Analyzer"/> for the given language /// </summary> /// <param name="index">Current search index</param> /// <param name="languageId">Language ID (LCID) of the needed language</param> /// <returns>Language-specific analyzer provided by <see cref="LanguageAnalyzerFactory"/></returns> public static Analyzer GetLanguageSpecificAnalyzer(this ICrmEntityIndex index, int languageId) { return(CreateSpecificAnalyzer(languageId, index.Version)); }
public UserQueryIndexer(ICrmEntityIndex index, string savedQueryName) : base(index, savedQueryName) { }