Search query in HTML field

Hi,

I have to make a query searching for some classes of some HTML tags in a field wich contains some HTML code. The field is data.content. But I cannot make a search with LIKE or fulltext(). It doesn’t work this search inside HTML tags.

Hi.

Not 100% sure if Im reading you right, but you want to search for html? HTML-area data are stripped for html-tags before indexed, since this is usually the most wanted behaviour.

Did I understand your problem correctly? I that case, if you need to store HTML-code to be available for search, you can use a normal text-field to store the data.

1 Like

Hi,
You did understand well. I really need to search among classes and html tags. And I cannot change everything now because I have many records since 2 years ago. I’ve built a function to search as I wish. But it took me 2 days to realize that I cannot do this with Enonic query.

Yes, I see your problem.
Its done that way to make it suit most case without users having to fiddle with this themselves.

It is possible to create a script to traverse your content, modify the content by copying the value from the html-area to a new field of type text-area, or depending on your scenario maybe extract the needed info without depending on searching the html-tags but rather use a category-tag or something.

The downside to this is that you will have make sure this field is populated for future content as well, possibly by a trigger on event node modified if not possible to mark manually.

1 Like