Empowering your Attribute’s Names
Today I was facing the following issue. I have an indexing system (read more here, here and here) using Lucene.Net that is working quite good. The drawback of the current implementation was that I couldn’t filter any to be indexed property decorated with the attribute. For example if I had a string property of my domain holding HTML, I wasn’t able to remove the HTML out of the string before indexing it.
I scratch my head some time, and finally came to a pragmatic solution.
For this pragmatic solution I used meta information in the name of the attribute. So the attribute decorate my code with a meta information and the name of the attribute contains by itself also meta information. This means that I enforce some rules in the naming of the attribute.
For example the first rule is the following, if the name of the attribute contains Html in whatever form, uppercase, lowercase, etc. the framework will realize that the property contains Html and that it needs to remove the Html tags out of the string on decode it.
If none of the naming rules match then it will use the content of the property directly.
So as a user of the indexing framework, I write one attribute named HTMLSearchableAttribute and decorate my properties and then the framework will clean automatically this string property before indexing the cleaned content with Lucene.Net.