Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I basically wish to create Examine indexset/indexer/searcher dynamically (through say an eventhandler). Is this at at all possible to create on the fly programmatically? A quick Google didn't bring back anything.
My set up is on v6.1.5, running on IIS7.5.
I have a multilingual site which gets deployed dependant on its market/language (eg. gl-en, fr-fr, de-de). This is a business concept rather than a .net culture, although they're loosely based on those ideas. We have a folder structure which dictates the Content structure.
These markets are then deployed as static files from an Umbraco authoring instance. While it may not be the best way to do things, it's the current way the site works and unfortunately that can not change for now.
I wish to add search functionality via Examine on a per market basis. This search application will live outside of this static file site and I wish to send the Examine indexes out to this app so it may search through them.
These sites get deployed along with the programmatically created index file for that market.
Routing will handle which index needs to be used based on a convention (eg. ExternalMarketSpecificglen_Searcher). I already have this set up to work with multiple searchers.
I'd rather not have one file as this would be giving the search app information which is potentially not live yet on the static website.
This is a possibility and the market root nodes rarely change at all. However it would be a nice to have to remove any developer intervention required to set up Search functionality for a market. Especially if a developer is not available when a new market is created or the team simply forgets this is a requirement.
Thanks for reading. Hopefully we can reach a solution.
I'm not sure but it worth to try adding them like this.
Code isn't finished just guidelines:
var indexer = new UmbracoContentIndexer(IIndexCriteria indexerData, Directory luceneDirectory, IDataService dataService, Analyzer analyzer, bool async);
var searcher = new UmbracoExamineSearcher(Directory luceneDirectory, Analyzer analyzer);
Thanks for this. I had something like this set up. It was just the last "Add()" part I was missing. You get karma!
Also there is a requirement to call Initialize(string key, NameValueCollection config) for both indexer and searcher before you can add them.
The purpose of such a thing is to init other attributes. Stuff you can typically set within a config file. For example check out the LuceneIndexer source from github.
One thing to note is, that this will not change any Examine config files, however the index files are created. I'll have a look exactly how these dynamically created indexes work after they've been created.
I had a look at Umbaco source and there is test class to get Index:
This may help:
public static UmbracoContentIndexer GetUmbracoIndexer(Lucene.Net.Store.Directory luceneDir, Analyzer anzer = null,IDataService dataService = null)
if (dataService == null)
dataService = new TestDataService();
if (analyzer == null)
analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29);
var indexSet = new IndexSet();
var indexCriteria = indexSet.ToIndexCriteria(dataService, UmbracoContentIndexer.IndexFieldPolicies);
var i = new UmbracoContentIndexer(indexCriteria,
luceneDir, //custom lucene directory
//i.IndexSecondsInterval = 1;
i.IndexingError += IndexingError;
Sorry to do this but, I'm going to have to say adding Indexers/Searchers at runtime is a bad idea and wouldn't recommend anyone do it programmatically.
Therefore I'll have to retract my selected answer so as not to give people the wrong idea.
Comment author was deleted
Can you give an explanation for your conclusion?
I'm trying to update the config file, so maybe I can just use a different approach.
It's been a while since I've written this code. However, as I recall, generally trying to modify the examine configuration files ended up in getting a "resolution is frozen" YSOD when editing the files during an Umbraco event handler.
As it's a readonly provider collection, I concluded the best way to go about adding in new markets was to manually add them in and check changes into our source control. It seemed to be something that needed to be done before the app started.
I ended up parsing the config files and appending new tags and it works a treat.
Thanks again for replying.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted