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.
Here's why
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.
So recap...
Static Website
gl/en/
fr/fr/
These sites get deployed along with the programmatically created index file for that market.
Search site (MVC)
gl/en/
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.
Why not do it via one file?
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.
Why not configure this via the config files?
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.
Jamie
Hi Benas,
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.
Hey folks,
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.
Hi Kevin,
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.
Examine - creating indexer/searcher programmatically
Hey all,
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.
Here's why
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.
So recap...
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.
Why not do it via one file?
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.
Why not configure this via the config files?
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.
Jamie
I'm not sure but it worth to try adding them like this.
Code isn't finished just guidelines:
Hi Benas,
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.
Thanks,
Jamie
I had a look at Umbaco source and there is test class to get Index:
This may help:
Hey folks,
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.
Thanks,
Jamie
Comment author was deleted
Jamie,
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.
kg
Hi Kevin,
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.
Thanks,
Jamie
Comment author was deleted
Thanks Jamie.
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...