I'm trying to determine whether I can retrieve a property (attribute) value from an xml blob stored in a FILESTREAM-enabled column using Full-text search. Here is a sample where message is a varbinary(max)
field that stores xml messages:
SELECT message FROM AuditTable
WHERE CONTAINS ( PROPERTY ( message, 'AccountNo' ), '123456');
On the MSDN page Search Document Properties with Search Property Lists, the summary at the top of the page includes this statement: "On the other hand, the XML IFilter does not emit properties."
I'm confused because it appears that this should work for an XML document. I'm starting to prep an environment to test, but I wanted to ask first just in case someone already knew.
Best Answer
If you have say a Word or Excel document, then these have documents well-known properties such as Author, Title, Keywords etc which you can associate with a search property list and then a full-text index. Properties available depending on their IFilter. You can use the PROPERTY keyword to query these properties.
However with an .xml file, it's unlikely the document has these custom properties, and what you really want to do is search the xml content. AccountNo sounds like just an attribute in the xml rather than a document property. You can search your xml using ordinary full-text search methods, however xml markup and attribute names are ignored in full-text indexes. You can query attribute and element content. You could also cast the file content to xml and use the built-in xml methods eg .query, .nodes, .value and .exist. Work through this demo and see if it makes sense:
I also did a test and could not get an xml doc to emit any properties, as suggested by the documentation. I could however get this to work with a standard Word document.