Thursday 11 December 2014

Searching for a field with a particular value in ADXStudio Portals...

...or perhaps the underlying Lucene.Net.
The Lucene index includes a field named _logicalname which contains the entity type, e.g. kbarticle, incident.
You think and are told that you can search for a specific value in a field - and thereby limit your results to entities of a particular type - by adding "_logicalname:kbarticle" into your query string.
You might find it doesn't work.
The reason appears to be that "kbarticle" gets truncated to "kbarticl" in Lucene.Net's search query.   (I'm guessing it's to do with stemming or something.)
The simple fix is to wildcard the value a bit by appending an asterisk.  A search for "_logicalname:kbarticle*" works.   (Actually, a search for kbarticlee seemed to as well.)

(There are other programmatic ways to restrict the entities that are searched for, but in my case I wanted to be able to perform a null or blank search that would return results for all entities of a particular type.  You can't actually search for null or blank, but a _logicalname search was a suitable equivalent.)